com.kuka.graph.util
Class ArraySetUnenforced<T>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by com.kuka.graph.util.ArraySetUnenforced<T>
Type Parameters:
T - the type of the elements in the set
All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess, Set<T>

public class ArraySetUnenforced<T>
extends ArrayList<T>
implements Set<T>

Helper for efficiently representing small sets whose elements are known to be unique by construction, implying we don't need to enforce the uniqueness property in the data structure itself. Use with caution.

Note that for equals/hashCode, the class implements the Set behavior (unordered), not the list behavior (ordered); the fact that it subclasses ArrayList should be considered an implementation detail.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArraySetUnenforced()
          Constructs an empty set with an initial capacity of ten.
ArraySetUnenforced(Collection<? extends T> c)
          Constructs a set containing the elements of the specified collection.
ArraySetUnenforced(int initialCapacity)
          Constructs an empty set with the specified initial capacity.
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

ArraySetUnenforced

public ArraySetUnenforced()
Constructs an empty set with an initial capacity of ten.


ArraySetUnenforced

public ArraySetUnenforced(Collection<? extends T> c)
Constructs a set containing the elements of the specified collection.

Parameters:
c - the collection whose elements are to be placed into this set
Throws:
NullPointerException - if the specified collection is null

ArraySetUnenforced

public ArraySetUnenforced(int initialCapacity)
Constructs an empty set with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the set
Throws:
IllegalArgumentException - if the specified initial capacity is negative
Method Detail

equals

public boolean equals(Object o)
Specified by:
equals in interface Collection<T>
Specified by:
equals in interface List<T>
Specified by:
equals in interface Set<T>
Overrides:
equals in class AbstractList<T>

hashCode

public int hashCode()
Specified by:
hashCode in interface Collection<T>
Specified by:
hashCode in interface List<T>
Specified by:
hashCode in interface Set<T>
Overrides:
hashCode in class AbstractList<T>


Copyright © 2019. All rights reserved.