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
@Immutableannotation.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 booleanadd(T element)Deprecated.booleanaddAll(Collection<? extends T> col)Deprecated.voidclear()Deprecated.booleancontains(Object key)booleancontainsAll(Collection<?> col)booleanequals(Object object)inthashCode()booleanisEmpty()Iterator<T>iterator()booleanremove(Object obj)Deprecated.booleanremoveAll(Collection<?> col)Deprecated.booleanretainAll(Collection<?> col)Deprecated.intsize()Object[]toArray()<T> T[]toArray(T[] array)StringtoString()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:
containsAllin interfaceCollection<T>- Specified by:
containsAllin 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.
-
-