⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinfolist.java

📁 本例中聊天服务器默认于本地8000端口建立服务; 本例中聊天客户端默认连接59.64.7.48地址8000端口服务器;因为客户端没有提供服务器IP设置接口
💻 JAVA
字号:
/*
 * Created on 2004-12-14
 *
 * To change the template for this generated file go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

/**
 * @author mq
 *
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */
import javax.swing.*;
import java.net.*;
import java.io.*;

public class UserInfoList {
	Node root;
	Node pointer;
	int  count;
	
	public UserInfoList()
	{
		root = new Node();
		root.next = null;
		pointer = null;
		count = 0;
	}
	
	public void add(Node n)
	{
		pointer = root;
		
		while(pointer.next != null)
		{
			pointer = pointer.next;
		}
		
		pointer.next = n;
		n.next = null;
		count ++;
		
	}
	
	public void del(Node n)
	{
		pointer = root;
		
		while(pointer.next != null)
		{
			if(pointer.next == n)
			{
				pointer.next = n.next;
				count --;
				
				break;
			}
			
			pointer = pointer.next;
		}
	}
	
	public int getCount()
	{
		return count;
	}
	
	public Node find(String username)
	{
		if(count == 0) return null;
		
		pointer = root;
		
		while(pointer.next != null)
		{
			pointer = pointer.next;
			
			if(pointer.username.equalsIgnoreCase(username))
			{
				return pointer;
			}
		}
		
		return null;
	}
	
	public Node find(int index)
	{
		if(count == 0) 
		{
			return null;
		} 
		
		if(index <  0) 
		{
			return null;
		} 
		
		pointer = root;
		
		int i = 0;
		while(i < index + 1)
		{
			if(pointer.next != null)
			{
				pointer = pointer.next;
			}
			else
			{
				return null;
			}
			
			i ++;
		}
		
		return pointer;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -