jist.swans.trans
Class PriorityList

java.lang.Object
  extended by jist.swans.trans.PriorityList

public class PriorityList
extends java.lang.Object

Data structure that holds TCP message and sorts them based on their sequence numbers.

Since:
SWANS1.0
Version:
$Id: PriorityList.java,v 1.5 2004/04/06 16:07:51 barr Exp $
Author:
Kelwin Tamtoro <kt222@cs.cornell.edu>, Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
private  java.util.List llist
          List of messages.
 
Constructor Summary
PriorityList()
          Constructor.
 
Method Summary
 int find(int seqNum)
          Find a TCP message given the sequence number.
 void insert(TransTcp.TcpMessage msg)
          Insert a message to the possible priority list.
 void printList()
          This method is used to print out the list content.
 void removeMessage(int seqNum)
          Removing a specific message.
 void removeMessages(int seqNum)
          Removing all messages that have number less than the given number.
 TransTcp.TcpMessage retrieve(int seqNum)
          Retrieve a message with given sequence number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

llist

private java.util.List llist
List of messages.

Constructor Detail

PriorityList

public PriorityList()
Constructor.

Method Detail

insert

public void insert(TransTcp.TcpMessage msg)
Insert a message to the possible priority list. Messages are stored in increasing order, ordered by the sequence number.

Parameters:
msg - TCP message to be inserted

find

public int find(int seqNum)
Find a TCP message given the sequence number.

Parameters:
seqNum - sequence number of message to search
Returns:
the position of the message; -1 if not found

retrieve

public TransTcp.TcpMessage retrieve(int seqNum)
Retrieve a message with given sequence number. (Returns null if message is not found)

Parameters:
seqNum - sequence number of the message
Returns:
TCP message

removeMessage

public void removeMessage(int seqNum)
Removing a specific message.

Parameters:
seqNum - sequence number of message to be removed

removeMessages

public void removeMessages(int seqNum)
Removing all messages that have number less than the given number. All messages with sequence number less than the given seqNum will be removed. (If they are equal, the message is not removed)

Parameters:
seqNum - messages with sequence number lower than this will be removed

printList

public void printList()
This method is used to print out the list content.