Package com.jcabi.immutable
Class ArraySet<T>
- java.lang.Object
-
- com.jcabi.immutable.ArraySet<T>
-
- Type Parameters:
T
- Value key type
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
@Immutable @Loggable(1) public final class ArraySet<T> extends Object implements Set<T>
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.Limitations: Encapsulated objects with exposed mutators can mutate their state. Since this Set implementation is backed by array,
complexity ofcontains(java.lang.Object)
is (O(n)).- Since:
- 0.1
- Suppressed Checkstyle violations:
- MissingDeprecatedCheck (270 lines)
-
-
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.boolean
contains(Object key)
boolean
containsAll(Collection<?> col)
boolean
equals(Object object)
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
boolean
remove(Object obj)
Deprecated.boolean
removeAll(Collection<?> col)
Deprecated.boolean
retainAll(Collection<?> col)
Deprecated.int
size()
Object[]
toArray()
<T> T[]
toArray(T[] array)
String
toString()
ArraySet<T>
with(Collection<T> vals)
Make a new one with some extra entries.ArraySet<T>
with(T value)
Make a new one with an extra entry.ArraySet<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.Set
spliterator
-
-
-
-
Constructor Detail
-
ArraySet
public ArraySet()
Public ctor.
-
ArraySet
public ArraySet(Collection<T> set)
Public ctor.- Parameters:
set
- Original set- Since:
- 0.12
-
-
Method Detail
-
with
public ArraySet<T> with(T value)
Make a new one with an extra entry.- Parameters:
value
- The value- Returns:
- New set
-
with
public ArraySet<T> with(Collection<T> vals)
Make a new one with some extra entries.- Parameters:
vals
- Values to add- Returns:
- New set
-
without
public ArraySet<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)
-
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.
-
-