| | |
| | | private SortedMap<ChangeNumber, UpdateMessage> map = |
| | | new TreeMap<ChangeNumber, UpdateMessage>(); |
| | | |
| | | // The total number of bytes for all the message in the queue. |
| | | private int bytesCount = 0; |
| | | |
| | | /** |
| | | * Return the first UpdateMessage in the MsgQueue. |
| | | * |
| | |
| | | * |
| | | * @return The number of elements in this MsgQueue. |
| | | */ |
| | | public int size() |
| | | public int count() |
| | | { |
| | | return map.size(); |
| | | } |
| | | |
| | | /** |
| | | * Returns the number of bytes in this MsgQueue. |
| | | * |
| | | * @return The number of bytes in this MsgQueue. |
| | | */ |
| | | public int bytesCount() |
| | | { |
| | | return bytesCount; |
| | | } |
| | | |
| | | /** |
| | | * Returns <tt>true</tt> if this MsgQueue contains no UpdateMessage. |
| | | * |
| | | * @return <tt>true</tt> if this MsgQueue contains no UpdateMessage. |
| | |
| | | public void add(UpdateMessage update) |
| | | { |
| | | map.put(update.getChangeNumber(), update); |
| | | bytesCount += update.size(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | UpdateMessage msg = map.get(map.firstKey()); |
| | | map.remove(msg.getChangeNumber()); |
| | | bytesCount -= msg.size(); |
| | | return msg; |
| | | } |
| | | |
| | |
| | | public void clear() |
| | | { |
| | | map.clear(); |
| | | bytesCount = 0; |
| | | } |
| | | } |