DJDoc v.1.0.0b-1

net.sf.djdoc.util
Class HitList<T extends Hittable>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by java.util.TreeSet<T>
              extended by net.sf.djdoc.util.HitList<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Set<T>, java.util.SortedSet<T>

public class HitList<T extends Hittable>
extends java.util.TreeSet<T>

The HitList class is an implementation of the SortedSet interface with a maximum size; attempts to add elements beyond that size will result cause the last elements (with respect to the Set's Comparator to be dropped from the set.

See Also:
Serialized Form

Constructor Summary
HitList(java.util.Comparator<? super T> c, int maxSize)
          Public constructor.
 
Method Summary
 boolean add(T obj)
          This method will attempt to add an object to this HitList.
 boolean addAll(java.util.Collection<? extends T> coll)
          This method attempts to add a whole collection of objects to this HitList by adding the members of the specified collection individually.
 java.lang.Object clone()
          This method will create a clone of this HitList.
 
Methods inherited from class java.util.TreeSet
clear, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray
 

Constructor Detail

HitList

public HitList(java.util.Comparator<? super T> c,
               int maxSize)
Public constructor.

Parameters:
c - The comparator by which the set's elements are to be compared
maxSize - The maximum size of this HitList
Method Detail

add

public boolean add(T obj)
This method will attempt to add an object to this HitList. If the set's maximal capacity is exceeded, the last element (with respect to the set's Comparator) is dropped.

Specified by:
add in interface java.util.Collection<T extends Hittable>
Specified by:
add in interface java.util.Set<T extends Hittable>
Overrides:
add in class java.util.TreeSet<T extends Hittable>
Parameters:
obj - The object to be added to the set
Returns:
true if the added element is contained in this set after addition; false otherwise

addAll

public boolean addAll(java.util.Collection<? extends T> coll)
This method attempts to add a whole collection of objects to this HitList by adding the members of the specified collection individually.

Specified by:
addAll in interface java.util.Collection<T extends Hittable>
Specified by:
addAll in interface java.util.Set<T extends Hittable>
Overrides:
addAll in class java.util.TreeSet<T extends Hittable>
Parameters:
coll - The collection to be added to this HitList
Returns:
true if this HitList changed as a result of the operation; false otherwise

clone

public java.lang.Object clone()
This method will create a clone of this HitList.

Overrides:
clone in class java.util.TreeSet<T extends Hittable>
Returns:
A HitList with the same maximal capacity, Comparator and the same member set as this one

DJDoc v.1.0.0b-1