Package com.jcabi.immutable
Class ArraySortedSet<T>
- java.lang.Object
-
- com.jcabi.immutable.ArraySortedSet<T>
-
- Type Parameters:
T
- Value key type
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
,SortedSet<T>
@Immutable @Loggable(1) public final class ArraySortedSet<T> extends Object implements SortedSet<T>
Sorted Set on top of array.This class is truly immutable. This means that it never changes its encapsulated values and is annotated with
@Immutable
annotation.Limitation: Encapsulated objects with exposed mutators can mutate their state.
- Since:
- 0.1
- Suppressed Checkstyle violations:
- MissingDeprecatedCheck (360 lines)
-
-
Constructor Summary
Constructors Constructor Description ArraySortedSet(ArrayComparator<T> comparator)
Public ctor.ArraySortedSet(ArrayComparator<T> comparator, T... set)
Public ctor.ArraySortedSet(ArraySortedSet<T> set, ArrayComparator<T> comparator)
Public ctor.ArraySortedSet(Iterable<T> set)
Public ctor, with default comparator.ArraySortedSet(Iterable<T> set, ArrayComparator<T> comparator)
Public ctor.ArraySortedSet(Collection<T> set, ArrayComparator<T> comparator)
Public ctor.ArraySortedSet(T... set)
Public ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
add(T element)
Deprecated.boolean
addAll(Collection<? extends T> col)
Deprecated.void
clear()
Deprecated.Comparator<? super T>
comparator()
boolean
contains(Object key)
boolean
containsAll(Collection<?> col)
boolean
equals(Object object)
T
first()
int
hashCode()
SortedSet<T>
headSet(T till)
boolean
isEmpty()
Iterator<T>
iterator()
T
last()
boolean
remove(Object obj)
Deprecated.boolean
removeAll(Collection<?> col)
Deprecated.boolean
retainAll(Collection<?> col)
Deprecated.int
size()
SortedSet<T>
subSet(T from, T till)
SortedSet<T>
tailSet(T from)
Object[]
toArray()
<T> T[]
toArray(T[] array)
String
toString()
ArraySortedSet<T>
with(Collection<T> vals)
Make a new one with some extra entries.ArraySortedSet<T>
with(T value)
Make a new one with an extra entry.ArraySortedSet<T>
without(T value)
Make a new one without an extra entry.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.SortedSet
spliterator
-
-
-
-
Constructor Detail
-
ArraySortedSet
public ArraySortedSet(ArrayComparator<T> comparator)
Public ctor.- Parameters:
comparator
- Comparator to use
-
ArraySortedSet
public ArraySortedSet(T... set)
Public ctor.- Parameters:
set
- Original set
-
ArraySortedSet
public ArraySortedSet(ArrayComparator<T> comparator, T... set)
Public ctor.- Parameters:
comparator
- The comparator to useset
- Original set
-
ArraySortedSet
public ArraySortedSet(Iterable<T> set)
Public ctor, with default comparator.- Parameters:
set
- Original set- Since:
- 0.12
-
ArraySortedSet
public ArraySortedSet(ArraySortedSet<T> set, ArrayComparator<T> comparator)
Public ctor.- Parameters:
set
- Original setcomparator
- Comparator to use
-
ArraySortedSet
public ArraySortedSet(Collection<T> set, ArrayComparator<T> comparator)
Public ctor.- Parameters:
set
- Original setcomparator
- Comparator to use
-
ArraySortedSet
public ArraySortedSet(Iterable<T> set, ArrayComparator<T> comparator)
Public ctor.- Parameters:
set
- Original setcomparator
- Comparator to use
-
-
Method Detail
-
with
public ArraySortedSet<T> with(T value)
Make a new one with an extra entry.- Parameters:
value
- The value- Returns:
- New set
-
with
public ArraySortedSet<T> with(Collection<T> vals)
Make a new one with some extra entries.- Parameters:
vals
- Values to add- Returns:
- New set
-
without
public ArraySortedSet<T> without(T value)
Make a new one without an extra entry.- Parameters:
value
- The value- Returns:
- New set
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object object)
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object key)
-
comparator
public Comparator<? super T> comparator()
- Specified by:
comparator
in interfaceSortedSet<T>
-
toArray
public Object[] toArray()
-
toArray
public <T> T[] toArray(T[] array)
-
add
@Deprecated public boolean add(T element)
Deprecated.
-
remove
@Deprecated public boolean remove(Object obj)
Deprecated.
-
containsAll
public boolean containsAll(Collection<?> col)
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
addAll
@Deprecated public boolean addAll(Collection<? extends T> col)
Deprecated.
-
retainAll
@Deprecated public boolean retainAll(Collection<?> col)
Deprecated.
-
removeAll
@Deprecated public boolean removeAll(Collection<?> col)
Deprecated.
-
clear
@Deprecated public void clear()
Deprecated.
-
-