Package org.biojava.utils
Class SmallSet
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet
-
- org.biojava.utils.SmallSet
-
- All Implemented Interfaces:
Iterable
,Collection
,Set
public class SmallSet extends AbstractSet
Lightweight implementation of Set which uses little memory to store a small number of items, at the expense of scalability. Not recomended for more than 20-30 items.This implementation has the useful property that the iteration order is the same as the order in which the items are added.
- Author:
- Matthew Pocock
-
-
Constructor Summary
Constructors Constructor Description SmallSet()
SmallSet(int size)
SmallSet(Collection col)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Object o)
boolean
contains(Object o)
Iterator
iterator()
int
size()
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
SmallSet
public SmallSet()
-
SmallSet
public SmallSet(int size)
-
SmallSet
public SmallSet(Collection col)
-
-
Method Detail
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection
- Specified by:
contains
in interfaceSet
- Overrides:
contains
in classAbstractCollection
-
size
public int size()
- Specified by:
size
in interfaceCollection
- Specified by:
size
in interfaceSet
- Specified by:
size
in classAbstractCollection
-
add
public boolean add(Object o)
- Specified by:
add
in interfaceCollection
- Specified by:
add
in interfaceSet
- Overrides:
add
in classAbstractCollection
-
iterator
public Iterator iterator()
- Specified by:
iterator
in interfaceCollection
- Specified by:
iterator
in interfaceIterable
- Specified by:
iterator
in interfaceSet
- Specified by:
iterator
in classAbstractCollection
-
-