public class FlyweightSet<E> extends AbstractSet<E>
get
method for supplying the FlyweightSet
with candidate flyweight instances.
Objects that do not customize the hashCode and equals methods don't make
sense to use as flyweights because each instance will be considered unique.
The object returned from the get
method will always be the same
as the one passed in.
Constructor and Description |
---|
FlyweightSet() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Object obj) |
protected boolean |
equals(E a,
E b) |
protected int |
hashCode(E obj) |
Iterator |
iterator() |
E |
put(E obj)
Pass in a candidate flyweight object and get a unique instance from this
set.
|
int |
size() |
String |
toString() |
equals, hashCode, removeAll
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray
parallelStream, removeIf, stream
public E put(E obj)
obj
- candidate flyweight; null is also acceptedpublic Iterator iterator()
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public boolean contains(Object obj)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
protected int hashCode(E obj)
Copyright © 2014 Macrofocus GmbH. All Rights Reserved.