public class Objects
extends java.lang.Object
implements java.util.Set<java.lang.Long>, java.io.Closeable, java.lang.Iterable<java.lang.Long>
It stores a collection of Sparksee object identifiers as a set. As a set, there is no order and no duplicated elements.
This class should be used just to store large collections. Otherwise, it is strongly recommended to use common classes from the language API.
This class is not thread-safe.
ObjectsIterator must be used to traverse all the elements into the set.
When the Objects instance is closed, it closes all existing and non-closed ObjectsIterator instances too.
Modifier and Type | Field and Description |
---|---|
static int |
InvalidOID
Invalid object identifier constant.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(long e)
Adds an element into the collection.
|
boolean |
add(java.lang.Long e)
Adds the specified element to this set if it is not already present (optional operation).
|
boolean |
addAll(java.util.Collection<? extends java.lang.Long> clctn)
Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
|
long |
any()
Gets an element from the collection.
|
void |
clear()
Clears the collection removing all its elements.
|
void |
close()
Closes the Objects instance.
|
static Objects |
combineDifference(Objects objs1,
Objects objs2)
Creates a new Objects instance which is the difference of the two given.
|
static Objects |
combineIntersection(Objects objs1,
Objects objs2)
Creates a new Objects instance which is the intersection of the two given.
|
static Objects |
combineUnion(Objects objs1,
Objects objs2)
Creates a new Objects instance which is the union of the two given.
|
boolean |
contains(java.lang.Object o)
Returns true if this collections contains the specified element or Objects.
|
boolean |
contains(Objects objs)
Check if this objects contains the other one.
|
boolean |
containsAll(java.util.Collection<?> clctn)
Returns true if this set contains all of the elements of the specified collection.
|
Objects |
copy()
Creates a new Objects instance as a copy of the given one.
|
long |
copy(Objects objs)
Performs the copy operation.
|
long |
count()
Gets the number of elements into the collection.
|
long |
difference(Objects objs)
Performs the difference operation.
|
boolean |
equals(java.lang.Object o)
Returns true if the collection is equal to the object.
|
boolean |
equals(Objects objs)
Checks if the given Objects contains the same information.
|
boolean |
exists(long e)
Gets if the given element exists into the collection.
|
long |
intersection(Objects objs)
Performs the intersection operation.
|
boolean |
isClosed()
Gets if Objects instance has been closed or not.
|
boolean |
isEmpty()
Returns true if this Objects contains no elements.
|
ObjectsIterator |
iterator()
Gets an ObjectsIterator.
|
ObjectsIterator |
iteratorFromElement(long e)
Gets an ObjectsIterator starting from the given element.
|
ObjectsIterator |
iteratorFromIndex(long index)
Gets an ObjectsIterator skipping index elements.
|
boolean |
remove(long e)
Removes an element from the collection.
|
boolean |
remove(java.lang.Object o)
Removes the specified element from this set if it is present (optional operation).
|
boolean |
removeAll(java.util.Collection<?> clctn)
Removes from this set all of its elements that are contained in the specified collection (optional operation).
|
boolean |
retainAll(java.util.Collection<?> clctn)
Retains only the elements in this set that are contained in the specified collection (optional operation).
|
Objects |
sample(Objects exclude,
long samples)
Creates a new Objects instance which is a sample of the calling one.
|
int |
size()
Gets the size of the collection.
|
java.lang.Object[] |
toArray()
Returns an array containing all of the object identifiers in this set.
|
<T> T[] |
toArray(T[] ts)
Returns an array containing all of the object identifiers in this set; the runtime type of the returned array is that of the specified array.
|
long |
union(Objects objs)
Performs the union operation.
|
public long copy(Objects objs)
This updates the Objects calling instance and copies the given Objects instance.
objs
- [in] Objects instance.public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<java.lang.Long>
equals
in interface java.util.Set<java.lang.Long>
equals
in class java.lang.Object
o
- object to compare with the collection.public long any() throws java.lang.RuntimeException, java.util.NoSuchElementException
java.lang.RuntimeException
- nulljava.util.NoSuchElementException
- whether the collection is empty.public boolean contains(Objects objs)
objs
- Objects collection.public static Objects combineIntersection(Objects objs1, Objects objs2)
Two given Objects belong to the same Session.
objs1
- [in] Objects instance.objs2
- [in] Objects instance.public ObjectsIterator iterator()
iterator
in interface java.lang.Iterable<java.lang.Long>
iterator
in interface java.util.Collection<java.lang.Long>
iterator
in interface java.util.Set<java.lang.Long>
public long union(Objects objs)
This adds all existing elements of the given Objects instance to the Objects calling instance
objs
- [in] Objects instance.public long intersection(Objects objs)
Updates the Objects calling instance setting those existing elements at both two collections and removing all others.
objs
- [in] Objects instance.public boolean remove(java.lang.Object o)
More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if the set contains such an element. Returns true if the set contained the specified element (or equivalently, if the set changed as a result of the call). (The set will not contain the specified element once the call returns.)
remove
in interface java.util.Collection<java.lang.Long>
remove
in interface java.util.Set<java.lang.Long>
o
- object to be removed from this set, if present.public void clear()
clear
in interface java.util.Collection<java.lang.Long>
clear
in interface java.util.Set<java.lang.Long>
public ObjectsIterator iteratorFromIndex(long index)
Objects collection has no order, so this method is implementation-dependent.
index
- [in] The number of elements to skip from the beginning. It must be in the range [0..Size).public boolean removeAll(java.util.Collection<?> clctn)
If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
removeAll
in interface java.util.Collection<java.lang.Long>
removeAll
in interface java.util.Set<java.lang.Long>
clctn
- collection that defines which elements will be removed from this set.public Objects copy()
public static Objects combineDifference(Objects objs1, Objects objs2)
Two given Objects belong to the same Session.
objs1
- [in] Objects instance.objs2
- [in] Objects instance.public <T> T[] toArray(T[] ts)
Obeys the general contract of the Collection.toArray(Object[]) method.
toArray
in interface java.util.Collection<java.lang.Long>
toArray
in interface java.util.Set<java.lang.Long>
ts
- the array into which the elements of this set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.public Objects sample(Objects exclude, long samples)
exclude
- [in] If not NULL, elements into this collection will be excluded from the resulting one.samples
- [in] Number of elements into the resulting collection.public boolean add(java.lang.Long e)
More formally, adds the specified element, o, to this set if this set contains no element e such that (o==null ? e==null : o.equals(e)). If this set already contains the specified element, the call leaves this set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements. The stipulation above does not imply that sets must accept all elements; sets may refuse to add any particular element, including null, and throwing an exception, as described in the specification for Collection.add. Individual set implementations should clearly document any restrictions on the the elements that they may contain.
add
in interface java.util.Collection<java.lang.Long>
add
in interface java.util.Set<java.lang.Long>
e
- element to be added to this set.public void close()
It must be called to ensure the integrity of all data.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean remove(long e)
e
- [in] Element to be removed.public ObjectsIterator iteratorFromElement(long e)
Objects collection has no order, so this method is implementation-dependent. e[in] The first element to traverse in the resulting
e
- [in] The first element to traverse in the resulting ObjectsIterator instance.public java.lang.Object[] toArray()
Obeys the general contract of the Collection.toArray method.
toArray
in interface java.util.Collection<java.lang.Long>
toArray
in interface java.util.Set<java.lang.Long>
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<java.lang.Long>
contains
in interface java.util.Set<java.lang.Long>
o
- element or Objects whose presence in this set is to be tested.public long count()
public boolean equals(Objects objs)
objs
- [in] Objects instance.public boolean containsAll(java.util.Collection<?> clctn)
If the specified collection is also a set, this method returns true if it is a subset of this set.
containsAll
in interface java.util.Collection<java.lang.Long>
containsAll
in interface java.util.Set<java.lang.Long>
clctn
- collection to be checked for containment in this set.public boolean isEmpty()
isEmpty
in interface java.util.Collection<java.lang.Long>
isEmpty
in interface java.util.Set<java.lang.Long>
public static Objects combineUnion(Objects objs1, Objects objs2)
Two given Objects belong to the same Session.
objs1
- [in] Objects instance.objs2
- [in] Objects instance.public boolean isClosed()
close()
public int size()
It is the same as count() if the number of elements is <= java.lang.Integer.MAX_VALUE, otherwise java.lang.Integer.MAX_VALUE is returned.
size
in interface java.util.Collection<java.lang.Long>
size
in interface java.util.Set<java.lang.Long>
public boolean exists(long e)
e
- [in] Element.public boolean addAll(java.util.Collection<? extends java.lang.Long> clctn)
If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.
addAll
in interface java.util.Collection<java.lang.Long>
addAll
in interface java.util.Set<java.lang.Long>
clctn
- collection whose elements are to be added to this set.public long difference(Objects objs)
This updates the Objects calling instance removing those existing elements at the given Objects instance.
objs
- [in] Objects instance.public boolean add(long e)
e
- [in] Element to be added.public boolean retainAll(java.util.Collection<?> clctn)
In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.
retainAll
in interface java.util.Collection<java.lang.Long>
retainAll
in interface java.util.Set<java.lang.Long>
clctn
- collection that defines which elements this set will retain.