Package org.djutils.immutablecollections
Interface ImmutableSet<E>
- Type Parameters:
E
- the type of content of this Set
- All Superinterfaces:
ImmutableCollection<E>
,Iterable<E>
,Serializable
- All Known Subinterfaces:
ImmutableNavigableSet<E>
,ImmutableSortedSet<E>
- All Known Implementing Classes:
ImmutableAbstractSet
,ImmutableHashSet
,ImmutableLinkedHashSet
,ImmutableTreeSet
A Set interface without the methods that can change it. The constructor of the ImmutableSet needs to be given an initial Set.
Copyright (c) 2016-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Force to redefine equals for the implementations of immutable collection classes.int
hashCode()
Force to redefine hashCode for the implementations of immutable collection classes.static <E> ImmutableSet<E>
of()
Return an empty ImmutableSet, backed by a LinkedHashSet.static <E> ImmutableSet<E>
of
(E v1) Return an ImmutableSet with 1 entry, backed by a LinkedHashSet.static <E> ImmutableSet<E>
of
(E v1, E v2) Return an ImmutableSet with 2 entries, backed by a LinkedHashSet.static <E> ImmutableSet<E>
of
(E v1, E v2, E v3) Return an ImmutableSet with 3 entries, backed by a LinkedHashSet.static <E> ImmutableSet<E>
of
(E v1, E v2, E v3, E v4) Return an ImmutableSet with 4 entries, backed by a LinkedHashSet.static <E> ImmutableSet<E>
of
(E v1, E v2, E v3, E v4, E v5, E... vn) Return an ImmutableSet with 5 or more entries, backed by a LinkedHashSet.toSet()
Returns a modifiable copy of this immutable set.toString()
Force to redefine toString.Methods inherited from interface org.djutils.immutablecollections.ImmutableCollection
contains, containsAll, containsAll, isCopy, isEmpty, isWrap, iterator, parallelStream, size, spliterator, stream, toArray, toArray, toCollection
-
Method Details
-
toSet
Returns a modifiable copy of this immutable set.- Returns:
- a modifiable copy of this immutable set.
-
equals
Force to redefine equals for the implementations of immutable collection classes.- Specified by:
equals
in interfaceImmutableCollection<E>
- Overrides:
equals
in classObject
- Parameters:
obj
- Object; the object to compare this collection with- Returns:
- whether the objects are equal
-
hashCode
int hashCode()Force to redefine hashCode for the implementations of immutable collection classes.- Specified by:
hashCode
in interfaceImmutableCollection<E>
- Overrides:
hashCode
in classObject
- Returns:
- the calculated hashCode
-
toString
String toString()Force to redefine toString. -
of
Return an empty ImmutableSet, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Returns:
- ImmutableSet<K, V>; an empty ImmutableSet
-
of
Return an ImmutableSet with 1 entry, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Parameters:
v1
- E; value 1- Returns:
- ImmutableSet<K, V>; an ImmutableSet with 1 entry, backed by a LinkedHashSet
-
of
Return an ImmutableSet with 2 entries, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Parameters:
v1
- E; value 1v2
- E; value 2- Returns:
- ImmutableSet<K, V>; an ImmutableSet with 2 entries, backed by a LinkedHashSet
-
of
Return an ImmutableSet with 3 entries, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Parameters:
v1
- E; value 1v2
- E; value 2v3
- E; value 3- Returns:
- ImmutableSet<K, V>; an ImmutableSet with 3 entries, backed by a LinkedHashSet
-
of
Return an ImmutableSet with 4 entries, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Parameters:
v1
- E; value 1v2
- E; value 2v3
- E; value 3v4
- E; value 4- Returns:
- ImmutableSet<K, V>; an ImmutableSet with 4 entries, backed by a LinkedHashSet
-
of
Return an ImmutableSet with 5 or more entries, backed by a LinkedHashSet.- Type Parameters:
E
- the value type- Parameters:
v1
- E; value 1v2
- E; value 2v3
- E; value 3v4
- E; value 4v5
- E; value 5vn
- E...; values 6 and beyond- Returns:
- ImmutableSet<K, V>; an ImmutableSet with 5 or more entries, backed by a LinkedHashSet
-