public class GridListSet<V> extends GridSerializableSet<V> implements Cloneable
Set based on internal list rather than hash table.
The order of the internal list is either insertion order or defined by
optionally provided Comparator.
Note that if 'strict' flag is false, then this set allows inconsistencies
between Object.equals(Object) and Comparator.compare(Object, Object)
methods. The equals(Object) method will always be used to determine
final equality. This allows to have multiple elements for which compare(Object)
method returns 0, but equals(Object) method returns false. The
reverse is also true, where equals(Object) may return true, but
compare(Object) method may return non-zero values.
In strict mode, which is default, Object.equals(Object) and
Comparator.compare(Object, Object) methods must be absolutely consistent with each other.
This set does not allow null values.
| Constructor and Description |
|---|
GridListSet()
Creates unsorted list set.
|
GridListSet(@Nullable Comparator<V> comp)
If comparator is not
null, then sorted list set will be created. |
GridListSet(@Nullable Comparator<V> comp,
boolean strict)
If comparator is not
null, then sorted list set will be created. |
GridListSet(GridListSet<V> copy)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(V val) |
V |
addx(V val)
Either adds a value to set or does nothing if value is already present.
|
protected Object |
clone()
Clones this set.
|
@Nullable Comparator<V> |
comparator()
Gets optional comparator for this set.
|
boolean |
contains(Object val) |
GridListSet<V> |
copy()
Creates a copy of this set.
|
V |
first()
Gets first element of this list.
|
V |
get(int idx)
Gets value at given index within internal list.
|
V |
get(V val)
Gets instance
e stored in this set for which e.equals(val)
returns true. |
Iterator<V> |
iterator() |
V |
last()
Gets last element of this list.
|
boolean |
remove(Object val) |
V |
removeFirst()
Removes the first element of this list.
|
V |
removeLast()
Removes the last element of this list.
|
V |
removex(V val)
Removes given value from the set and returns the instance stored in the set
or
null if value was not found. |
int |
size() |
boolean |
strict()
Gets value of
strict flag for this set. |
String |
toString() |
GridListSet<V> |
toSynchronized()
Creates a synchronized instance of this set.
|
List<V> |
values()
Gets a copy of the internal list.
|
equals, hashCode, removeAlladdAll, clear, containsAll, isEmpty, retainAll, toArray, toArrayfinalize, getClass, notify, notifyAll, wait, wait, waitaddAll, clear, containsAll, isEmpty, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streampublic GridListSet()
public GridListSet(@Nullable
@Nullable Comparator<V> comp)
null, then sorted list set will be created.
Values will be sorted according to provided comparator.comp - Optional comparator to sort values.public GridListSet(@Nullable
@Nullable Comparator<V> comp,
boolean strict)
null, then sorted list set will be created.
Values will be sorted according to provided comparator.comp - Optional comparator to sort values.strict - Strict flag.public GridListSet(GridListSet<V> copy)
copy - Set to copy from.public boolean strict()
strict flag for this set.strict flag for this set.@Nullable public @Nullable Comparator<V> comparator()
public boolean add(V val)
add in interface Collection<V>add in interface Set<V>add in class AbstractCollection<V>@Nullable public V addx(V val)
val - Value to add.null if value was added.@Nullable public V removeFirst()
null if list is empty.@Nullable public V removeLast()
null if list is empty.@Nullable public V first()
null if list is empty.@Nullable public V last()
null if list is empty.public boolean remove(Object val)
remove in interface Collection<V>remove in interface Set<V>remove in class AbstractCollection<V>@Nullable public V removex(V val)
null if value was not found.val - Value to remove.null.@Nullable public V get(V val)
e stored in this set for which e.equals(val)
returns true.val - Value to check for equality.e.equals(val)
returns true.public V get(int idx)
idx - Index to get value at (must be non-negative and less than size()).public boolean contains(Object val)
contains in interface Collection<V>contains in interface Set<V>contains in class AbstractCollection<V>public GridListSet<V> copy()
public int size()
size in interface Collection<V>size in interface Set<V>size in class AbstractCollection<V>public List<V> values()
protected Object clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic String toString()
toString in class AbstractCollection<V>public GridListSet<V> toSynchronized()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.11.1 Release Date : December 20 2021