E - the type of entry stored in this set.public class DSet<E extends DSet.Entry> extends Object implements Iterable<E>, Streamable, Cloneable
Classes that wish to act as set entries must implement the DSet.Entry interface which
extends Streamable and adds the requirement that the object provide a key which will be
used to identify entry equality. Thus an entry is declared to be in a set of the object returned
by that entry's DSet.Entry.getKey() method is equal (using Object.equals(java.lang.Object)) to the entry
returned by the DSet.Entry.getKey() method of some other entry in the set. Additionally, in the
case of entry removal, only the key for the entry to be removed will be transmitted with the
removal event to save network bandwidth. Lastly, the object returned by DSet.Entry.getKey()
must be a Streamable type.
| Modifier and Type | Class and Description |
|---|---|
static interface |
DSet.Entry
Entries of the set must implement this interface.
|
Streamable.Closure| Constructor and Description |
|---|
DSet()
Constructs an empty distributed set.
|
DSet(E[] source)
Creates a distributed set and populates it with values from the supplied array.
|
DSet(Iterable<? extends E> source)
Creates a distributed set and populates it with values from the supplied iterator.
|
DSet(Iterator<? extends E> source)
Creates a distributed set and populates it with values from the supplied iterator.
|
| Modifier and Type | Method and Description |
|---|---|
Set<E> |
asSet()
Creates an immutable view of this distributed set as a Java set.
|
DSet<E> |
clone()
Generates a shallow copy of this object.
|
static int |
compare(Comparable<?> c1,
Comparable<?> c2)
Compares the first comparable to the second.
|
boolean |
contains(E elem)
Returns true if the set contains an entry whose
getKey() method returns a key
that equals() the key returned by getKey() of the supplied
entry. |
boolean |
containsKey(Comparable<?> key)
Returns true if an entry in the set has a key that
equals() the supplied
key. |
Iterator<E> |
entries()
Deprecated.
|
E |
get(Comparable<?> key)
Returns the entry that matches (
getKey().equals(key)) the specified key or null
if no entry could be found that matches the key. |
boolean |
isEmpty()
Returns true if this set contains no entries.
|
Iterator<E> |
iterator()
Returns an iterator over the entries of this set.
|
static <E extends DSet.Entry> |
newDSet()
Creates a new DSet of the appropriate generic type.
|
static <E extends DSet.Entry> |
newDSet(Iterable<? extends E> source)
Creates a new DSet of the appropriate generic type.
|
void |
readObject(ObjectInputStream in)
Custom reader method.
|
int |
size()
Returns the number of entries in this set.
|
E[] |
toArray(E[] array)
Deprecated.
use
clone() or toArrayList(). |
Object[] |
toArray(Object[] array)
Deprecated.
use
clone() or toArrayList(). |
ArrayList<E> |
toArrayList()
Copies the elements of this distributed set into a newly created
ArrayList. |
String |
toString() |
DSet<E> |
typedClone()
Deprecated.
clone() works just fine now.
|
void |
writeObject(ObjectOutputStream out)
Custom writer method.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic DSet(Iterable<? extends E> source)
source - an iterator from which we will initially populate the set.public DSet(Iterator<? extends E> source)
source - an iterator from which we will initially populate the set.public DSet(E[] source)
source - an array from which we will initially populate the set.public DSet()
public static <E extends DSet.Entry> DSet<E> newDSet()
public static <E extends DSet.Entry> DSet<E> newDSet(Iterable<? extends E> source)
public static int compare(Comparable<?> c1, Comparable<?> c2)
DSet.Entry values.public boolean isEmpty()
public int size()
public boolean contains(E elem)
getKey() method returns a key
that equals() the key returned by getKey() of the supplied
entry. Returns false otherwise.public boolean containsKey(Comparable<?> key)
equals() the supplied
key. Returns false otherwise.public E get(Comparable<?> key)
getKey().equals(key)) the specified key or null
if no entry could be found that matches the key.@Deprecated public Iterator<E> entries()
public Iterator<E> iterator()
iterator in interface Iterable<E extends DSet.Entry>public ArrayList<E> toArrayList()
ArrayList.@Deprecated public E[] toArray(E[] array)
clone() or toArrayList().@Deprecated public Object[] toArray(Object[] array)
clone() or toArrayList().@Deprecated public DSet<E> typedClone()
public void writeObject(ObjectOutputStream out) throws IOException
IOExceptionpublic void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionCopyright © 2015. All rights reserved.