Class Objects
- All Implemented Interfaces:
Closeable, AutoCloseable, Iterable<Long>, Collection<Long>, Set<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.
- Author:
- Sparsity Technologies http://www.sparsity-technologies.com
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(long e) Adds an element into the collection.booleanAdds the specified element to this set if it is not already present (optional operation).booleanaddAll(Collection<? extends Long> clctn) Adds all of the elements in the specified collection to this set if they're not already present (optional operation).longany()Gets an element from the collection.voidclear()Clears the collection removing all its elements.voidclose()Closes the Objects instance.static ObjectscombineDifference(Objects objs1, Objects objs2) Creates a new Objects instance which is the difference of the two given.static ObjectscombineIntersection(Objects objs1, Objects objs2) Creates a new Objects instance which is the intersection of the two given.static ObjectscombineUnion(Objects objs1, Objects objs2) Creates a new Objects instance which is the union of the two given.booleanCheck if this objects contains the other one.booleanReturns true if this collections contains the specified element or Objects.booleancontainsAll(Collection<?> clctn) Returns true if this set contains all of the elements of the specified collection.copy()Creates a new Objects instance as a copy of the given one.longPerforms the copy operation.longcount()Gets the number of elements into the collection.longdifference(Objects objs) Performs the difference operation.booleanChecks if the given Objects contains the same information.booleanReturns true if the collection is equal to the object.booleanexists(long e) Gets if the given element exists into the collection.longintersection(Objects objs) Performs the intersection operation.booleanisClosed()Gets if Objects instance has been closed or not.booleanisEmpty()Returns true if this Objects contains no elements.iterator()Gets an ObjectsIterator.iteratorFromElement(long e) Gets an ObjectsIterator starting from the given element.iteratorFromIndex(long index) Gets an ObjectsIterator skipping index elements.booleanremove(long e) Removes an element from the collection.booleanRemoves the specified element from this set if it is present (optional operation).booleanremoveAll(Collection<?> clctn) Removes from this set all of its elements that are contained in the specified collection (optional operation).booleanretainAll(Collection<?> clctn) Retains only the elements in this set that are contained in the specified collection (optional operation).Creates a new Objects instance which is a sample of the calling one.intsize()Gets the size of the collection.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.longPerforms the union operation.Methods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface Set
hashCode, spliterator
-
Field Details
-
InvalidOID
public static int InvalidOIDInvalid object identifier constant.
-
-
Method Details
-
copy
Performs the copy operation.This updates the Objects calling instance and copies the given Objects instance.
- Parameters:
objs- [in] Objects instance.- Returns:
- Number of elements into the collection once the operation has been executed.
-
equals
Returns true if the collection is equal to the object. -
any
Gets an element from the collection.Errorfor other issues.
- Returns:
- Any element from the collection.
- Throws:
RuntimeException- nullNoSuchElementException- whether the collection is empty.
-
contains
Check if this objects contains the other one.- Parameters:
objs- Objects collection.- Returns:
- True if it contains the given object.
-
combineIntersection
-
iterator
Gets an ObjectsIterator. -
union
Performs the union operation.This adds all existing elements of the given Objects instance to the Objects calling instance
- Parameters:
objs- [in] Objects instance.- Returns:
- Number of elements into the collection once the operation has been executed.
-
intersection
Performs the intersection operation.Updates the Objects calling instance setting those existing elements at both two collections and removing all others.
- Parameters:
objs- [in] Objects instance.- Returns:
- Number of elements into the collection once the operation has been executed.
-
remove
Removes the specified element from this set if it is present (optional operation).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.)
-
clear
-
iteratorFromIndex
Gets an ObjectsIterator skipping index elements.Objects collection has no order, so this method is implementation-dependent.
- Parameters:
index- [in] The number of elements to skip from the beginning. It must be in the range [0..Size).- Returns:
- ObjectsIterator instance.
-
removeAll
Removes from this set all of its elements that are contained in the specified collection (optional operation).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.
-
copy
Creates a new Objects instance as a copy of the given one.- Returns:
- The new Objects instance.
-
combineDifference
-
toArray
public <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.Obeys the general contract of the Collection.toArray(Object[]) method.
- Specified by:
toArrayin interfaceCollection<Long>- Specified by:
toArrayin interfaceSet<Long>- Parameters:
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.- Returns:
- an array containing the elements of this set.
-
sample
Creates a new Objects instance which is a sample of the calling one.- Parameters:
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.- Returns:
- Sample collection.
-
add
Adds the specified element to this set if it is not already present (optional operation).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.
-
close
public void close()Closes the Objects instance.It must be called to ensure the integrity of all data.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
remove
public boolean remove(long e) Removes an element from the collection.- Parameters:
e- [in] Element to be removed.- Returns:
- TRUE if the element is removed, FALSE if the element was not into the collection.
-
iteratorFromElement
Gets an ObjectsIterator starting from the given element.Objects collection has no order, so this method is implementation-dependent. e[in] The first element to traverse in the resulting
- Parameters:
e- [in] The first element to traverse in the resulting ObjectsIterator instance.- Returns:
- ObjectsIterator instance.
-
toArray
Returns an array containing all of the object identifiers in this set.Obeys the general contract of the Collection.toArray method.
-
contains
Returns true if this collections contains the specified element or Objects. -
count
public long count()Gets the number of elements into the collection.- Returns:
- The number of elements into the collection.
-
equals
Checks if the given Objects contains the same information.- Parameters:
objs- [in] Objects instance.- Returns:
- True if the objects are equal or false otherwise.
-
containsAll
Returns true if this set contains all of the elements of the specified collection.If the specified collection is also a set, this method returns true if it is a subset of this set.
- Specified by:
containsAllin interfaceCollection<Long>- Specified by:
containsAllin interfaceSet<Long>- Parameters:
clctn- collection to be checked for containment in this set.- Returns:
- true if this set contains all of the elements of the specified collection.
-
isEmpty
-
combineUnion
-
isClosed
public boolean isClosed()Gets if Objects instance has been closed or not.- Returns:
- TRUE if the Objects instance has been closed, FALSE otherwise.
- See Also:
-
size
public int size()Gets the size of the collection.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.
-
exists
public boolean exists(long e) Gets if the given element exists into the collection.- Parameters:
e- [in] Element.- Returns:
- TRUE if the element exists into the collection, FALSE otherwise.
-
addAll
Adds all of the elements in the specified collection to this set if they're not already present (optional operation).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.
-
difference
Performs the difference operation.This updates the Objects calling instance removing those existing elements at the given Objects instance.
- Parameters:
objs- [in] Objects instance.- Returns:
- Number of elements into the collection once the operation has been executed.
-
add
public boolean add(long e) Adds an element into the collection.- Parameters:
e- [in] Element to be added.- Returns:
- TRUE if the element is added, FALSE if the element was already into the collection.
-
retainAll
Retains only the elements in this set that are contained in the specified collection (optional operation).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.
-