userinfolist.java
来自「本例中聊天服务器默认于本地8000端口建立服务; 本例中聊天客户端默认连接59」· Java 代码 · 共 120 行
JAVA
120 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?