Top Description Inners Fields Constructors Methods
io.vavr.collection

public final Class LinkedHashSet<T>

extends Object
implements Set<T>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, io.vavr.collection.Set, io.vavr.Function1, java.util.function.Function, io.vavr.collection.Traversable, io.vavr.Value, java.lang.Iterable, io.vavr.collection.Foldable
Type Parameters
<T>
Component type
Imports
io.vavr.*, io.vavr.control.Option, java.io.*, java.util.ArrayList, .Comparator, .NoSuchElementException, .Objects, java.util.function.*, java.util.stream.Collector

An immutable HashSet implementation that has predictable (insertion-order) iteration.
Author
Ruslan Sennov, Patryk Najda, Daniel Dietrich

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
LinkedHashSet.SerializationProxy<
The component type of the underlying list.
T
>

A serialization proxy which, in this context, is used to deserialize immutable, linked Lists with final instance fields.

Field Summary

Modifier and TypeField and Description
private static final LinkedHashSet<?>
private final LinkedHashMap<T, Object>
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public LinkedHashSet<T>

Returns:

A new set containing all elements of this set and also element.
add
(T
The element to be added.
element
)

Implements io.vavr.collection.Set.add.

Add the given element to this set, replacing existing one if it is already contained.

public LinkedHashSet<T>

Returns:

A new set containing all elements of this set and the given elements, if not already contained.
addAll
(Iterable<? extends T>
The elements to be added.
elements
)

Implements io.vavr.collection.Set.addAll.

Adds all of the given elements to this set, replacing existing one if they are not already contained.

private static <T> LinkedHashMap<T, Object>
addAll(LinkedHashMap<T, Object> initial, Iterable<? extends T> additional)

public <R> LinkedHashSet<R>
collect(PartialFunction<? super T, ? extends R>
A function that is not necessarily defined of all elements of this traversable.
partialFunction
)

Implements io.vavr.collection.Set.collect.

Collects all elements that are in the domain of the given partialFunction by mapping the elements to type R.

public static <
Component type of the LinkedHashSet.
T
>
Collector<T, ArrayList<T>, LinkedHashSet<T>>

Returns:

A io.vavr.collection.LinkedHashSet Collector.
collector
()

Returns a Collector which may be used in conjunction with java.util.stream.Stream#collect(Collector) to obtain a LinkedHashSet.

public boolean
contains(T
An Object of type A, may be null.
element
)

Implements io.vavr.collection.Set.contains.

Shortcut for exists(e -> Objects.equals(e, element)), tests if the given element is contained.

public LinkedHashSet<T>
diff(Set<? extends T>
Elements to be removed from this set.
elements
)

Implements io.vavr.collection.Set.diff.

Calculates the difference between this set and another set.

public LinkedHashSet<T>
distinct()

Implements io.vavr.collection.Set.distinct.

Returns a new version of this which contains no duplicates.

public LinkedHashSet<T>
distinctBy(Comparator<? super T>
A comparator
comparator
)

Implements io.vavr.collection.Set.distinctBy.

Returns a new version of this which contains no duplicates.

public <U> LinkedHashSet<T>
distinctBy(Function<? super T, ? extends U>
A key extractor
keyExtractor
)

Implements io.vavr.collection.Set.distinctBy.

Returns a new version of this which contains no duplicates.

public LinkedHashSet<T>
drop(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Set.drop.

Drops the first n elements of this or all elements, if this length < n.

public LinkedHashSet<T>
dropRight(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Set.dropRight.

Drops the last n elements of this or all elements, if this length < n.

public LinkedHashSet<T>
dropUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.Set.dropUntil.

Drops elements until the predicate holds for the current element.

public LinkedHashSet<T>
dropWhile(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.Set.dropWhile.

Drops elements while the predicate holds for the current element.

public static <T> LinkedHashSet<T>
public boolean
equals(Object
an object, may be null
o
)

Overrides java.lang.Object.equals.

Implements io.vavr.collection.Traversable.equals.

In Vavr there are four basic classes of collections:

  • Seq (sequential elements)
  • Set (distinct elements)
  • Map (indexed elements)
  • Multimap (indexed collections)
public static <
Component type of the LinkedHashSet
T
>
LinkedHashSet<T>

Returns:

A LinkedHashSet of size n, where each element contains the result supplied by s.
fill
(int
The number of elements in the LinkedHashSet
n
,
Supplier<? extends T>
The Supplier computing element values
s
)

Returns a LinkedHashSet containing tuples returned by n calls to a given Supplier s.

public LinkedHashSet<T>
filter(Predicate<? super T>
A predicate
predicate
)

Implements io.vavr.collection.Set.filter.

Returns a new traversable consisting of all elements which satisfy the given predicate.

public <U> LinkedHashSet<U>
flatMap(Function<? super T, ? extends Iterable<? extends U>>
A mapper
mapper
)

Implements io.vavr.collection.Set.flatMap.

FlatMaps this Traversable.

public <U> U
foldRight(U
A zero element to start with.
zero
,
BiFunction<? super T, ? super U, ? extends U>
A function which combines elements.
f
)

Implements io.vavr.collection.Traversable.foldRight.

Folds this elements from the right, starting with zero and successively calling combine.

public <C> Map<C, LinkedHashSet<T>>
groupBy(Function<? super T, ? extends C>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.Set.groupBy.

Groups this elements by classifying the elements.

public Iterator<LinkedHashSet<T>>
grouped(int
a positive block size
size
)

Implements io.vavr.collection.Set.grouped.

Groups this Traversable into fixed size blocks.

public boolean
hasDefiniteSize()

Implements io.vavr.collection.Traversable.hasDefiniteSize.

Checks if this Traversable is known to have a finite size.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.collection.Traversable.hashCode.

Returns the hash code of this collection.

public T
head()

Implements io.vavr.collection.Traversable.head.

Returns the first element of a non-empty Traversable.

public Option<T>
headOption()

Overrides default io.vavr.collection.Traversable.headOption.

Returns the first element of a non-empty Traversable as Option.

public LinkedHashSet<T>
init()

Implements io.vavr.collection.Set.init.

Dual of tail(), returning all elements except the last.

public Option<LinkedHashSet<T>>
initOption()

Implements io.vavr.collection.Set.initOption.

Dual of tailOption(), returning all elements except the last as Option.

public LinkedHashSet<T>
intersect(Set<? extends T>
the set to intersect with.
elements
)

Implements io.vavr.collection.Set.intersect.

Computes the intersection between this set and another set.

public boolean

Returns:

false
isAsync
()

Implements io.vavr.Value.isAsync.

An LinkedHashSet's value is computed synchronously.

public boolean
isEmpty()

Overrides default io.vavr.collection.Traversable.isEmpty.

Checks if this Traversable is empty.

public boolean

Returns:

false
isLazy
()

Implements io.vavr.Value.isLazy.

An LinkedHashSet's value is computed eagerly.

public boolean
isSequential()

Overrides default io.vavr.collection.Traversable.isSequential.

Checks if the elements of this Traversable appear in encounter order.

public boolean
isTraversableAgain()

Implements io.vavr.collection.Traversable.isTraversableAgain.

Checks if this Traversable can be repeatedly traversed.

public Iterator<T>
iterator()

Implements io.vavr.collection.Set.iterator.

An iterator by means of head() and tail().

public T
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public int
length()

Implements io.vavr.collection.Set.length.

Computes the number of elements of this Traversable.

public <U> LinkedHashSet<U>
map(Function<? super T, ? extends U>
A mapper.
mapper
)

Implements io.vavr.collection.Set.map.

Maps the elements of this Traversable to elements of a new type preserving their order, if any.

public String
mkString(CharSequence
prefix of the resulting string
prefix
,
CharSequence
A delimiter string put between string representations of elements of this
delimiter
,
CharSequence
suffix of the resulting string
suffix
)

Overrides default io.vavr.collection.Traversable.mkString.

Joins the string representations of this elements using a specific delimiter, prefix and suffix.

public static <
Component type of the linkedHashSet.
T
>
LinkedHashSet<T>

Returns:

the given linkedHashSet instance as narrowed type LinkedHashSet<T>.
narrow
(LinkedHashSet<? extends T>
A LinkedHashSet.
linkedHashSet
)

Narrows a widened LinkedHashSet<?

public static <
The component type
T
>
LinkedHashSet<T>

Returns:

A new LinkedHashSet instance containing the given element
of
(T
An element.
element
)

Returns a singleton LinkedHashSet, i.e. a LinkedHashSet of one element.

public static <
Component type of the LinkedHashSet.
T
>
LinkedHashSet<T>

Returns:

A set containing the given elements.
of
(T...
Zero or more elements.
elements
)

Creates a LinkedHashSet of the given elements.

public static <
The value type
T
>
LinkedHashSet<T>

Returns:

A new LinkedHashSet containing the given entries
ofAll
(Iterable<? extends T>
Set elements
elements
)

Creates a LinkedHashSet of the given elements.

public static <
Component type of the Stream.
T
>
LinkedHashSet<T>

Returns:

A LinkedHashSet containing the given elements in the same order.
ofAll
(Stream<? extends T> javaStream)

Creates a LinkedHashSet that contains the elements of the given java.util.stream.Stream.

public static LinkedHashSet<Boolean>

Returns:

A new LinkedHashSet of Boolean values
ofAll
(boolean...
boolean values
elements
)

Creates a LinkedHashSet from boolean values.

public static LinkedHashSet<Byte>

Returns:

A new LinkedHashSet of Byte values
ofAll
(byte...
byte values
elements
)

Creates a LinkedHashSet from byte values.

public static LinkedHashSet<Character>

Returns:

A new LinkedHashSet of Character values
ofAll
(char...
char values
elements
)

Creates a LinkedHashSet from char values.

public static LinkedHashSet<Double>

Returns:

A new LinkedHashSet of Double values
ofAll
(double...
double values
elements
)

Creates a LinkedHashSet from double values.

public static LinkedHashSet<Float>

Returns:

A new LinkedHashSet of Float values
ofAll
(float...
a float values
elements
)

Creates a LinkedHashSet from float values.

public static LinkedHashSet<Integer>

Returns:

A new LinkedHashSet of Integer values
ofAll
(int...
int values
elements
)

Creates a LinkedHashSet from int values.

public static LinkedHashSet<Long>

Returns:

A new LinkedHashSet of Long values
ofAll
(long...
long values
elements
)

Creates a LinkedHashSet from long values.

public static LinkedHashSet<Short>

Returns:

A new LinkedHashSet of Short values
ofAll
(short...
short values
elements
)

Creates a LinkedHashSet from short values.

public LinkedHashSet<T>
orElse(Iterable<? extends T>
An alternative Traversable
other
)

Implements io.vavr.collection.Set.orElse.

Returns this Traversable if it is nonempty, otherwise return the alternative.

public LinkedHashSet<T>
orElse(Supplier<? extends Iterable<? extends T>>
An alternative Traversable supplier
supplier
)

Implements io.vavr.collection.Set.orElse.

Returns this Traversable if it is nonempty, otherwise return the result of evaluating supplier.

public Tuple2<LinkedHashSet<T>, LinkedHashSet<T>>
partition(Predicate<? super T>
A predicate which classifies an element if it is in the first or the second traversable.
predicate
)

Implements io.vavr.collection.Set.partition.

Creates a partition of this Traversable by splitting this elements in two in distinct traversables according to a predicate.

public LinkedHashSet<T>
peek(Consumer<? super T>
The action that will be performed on the element(s).
action
)

Implements io.vavr.collection.Set.peek.

Performs the given action on the first element if this is an eager implementation.

public static LinkedHashSet<Integer>

Returns:

a range of int values as specified or the empty range if from >= toExclusive
range
(int
the first number
from
,
int
the last number + 1
toExclusive
)

Creates a LinkedHashSet of int numbers starting from from, extending to toExclusive - 1.

public static LinkedHashSet<Character>
range(char from, char toExclusive)

public static LinkedHashSet<Long>

Returns:

a range of long values as specified or the empty range if from >= toExclusive
range
(long
the first number
from
,
long
the last number + 1
toExclusive
)

Creates a LinkedHashSet of long numbers starting from from, extending to toExclusive - 1.

public static LinkedHashSet<Integer>

Returns:

a range of long values as specified or the empty range if
from >= toInclusive and step > 0 or
from <= toInclusive and step < 0
rangeBy
(int
the first number
from
,
int
the last number + 1
toExclusive
,
int
the step
step
)

Creates a LinkedHashSet of int numbers starting from from, extending to toExclusive - 1, with step.

public static LinkedHashSet<Character>
rangeBy(char from, char toExclusive, int step)

public static LinkedHashSet<Double>
rangeBy(double from, double toExclusive, double step)

public static LinkedHashSet<Long>

Returns:

a range of long values as specified or the empty range if
from >= toInclusive and step > 0 or
from <= toInclusive and step < 0
rangeBy
(long
the first number
from
,
long
the last number + 1
toExclusive
,
long
the step
step
)

Creates a LinkedHashSet of long numbers starting from from, extending to toExclusive - 1, with step.

public static LinkedHashSet<Integer>

Returns:

a range of int values as specified or the empty range if from > toInclusive
rangeClosed
(int
the first number
from
,
int
the last number
toInclusive
)

Creates a LinkedHashSet of int numbers starting from from, extending to toInclusive.

public static LinkedHashSet<Character>
rangeClosed(char from, char toInclusive)

public static LinkedHashSet<Long>

Returns:

a range of long values as specified or the empty range if from > toInclusive
rangeClosed
(long
the first number
from
,
long
the last number
toInclusive
)

Creates a LinkedHashSet of long numbers starting from from, extending to toInclusive.

public static LinkedHashSet<Integer>

Returns:

a range of int values as specified or the empty range if
from > toInclusive and step > 0 or
from < toInclusive and step < 0
rangeClosedBy
(int
the first number
from
,
int
the last number
toInclusive
,
int
the step
step
)

Creates a LinkedHashSet of int numbers starting from from, extending to toInclusive, with step.

public static LinkedHashSet<Character>
rangeClosedBy(char from, char toInclusive, int step)

public static LinkedHashSet<Double>
rangeClosedBy(double from, double toInclusive, double step)

public static LinkedHashSet<Long>

Returns:

a range of int values as specified or the empty range if
from > toInclusive and step > 0 or
from < toInclusive and step < 0
rangeClosedBy
(long
the first number
from
,
long
the last number
toInclusive
,
long
the step
step
)

Creates a LinkedHashSet of long numbers starting from from, extending to toInclusive, with step.

private void
readObject(ObjectInputStream
An object serialization stream.
stream
)

readObject method for the serialization proxy pattern.

public LinkedHashSet<T>
reject(Predicate<? super T>
A predicate
predicate
)

Implements io.vavr.collection.Set.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

public LinkedHashSet<T>
remove(T
The element to be removed from this set.
element
)

Implements io.vavr.collection.Set.remove.

Removes a specific element from this set, if present.

public LinkedHashSet<T>
removeAll(Iterable<? extends T>
The elements to be removed from this set.
elements
)

Implements io.vavr.collection.Set.removeAll.

Removes all of the given elements from this set, if present.

public LinkedHashSet<T>
replace(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.Set.replace.

Replaces the first occurrence (if exists) of the given currentElement with newElement.

public LinkedHashSet<T>
replaceAll(T
An element to be substituted.
currentElement
,
T
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.Set.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

public LinkedHashSet<T>
retainAll(Iterable<? extends T>
Elements to be kept.
elements
)

Implements io.vavr.collection.Set.retainAll.

Keeps all occurrences of the given elements from this.

public LinkedHashSet<T>
scan(T
neutral element for the operator op
zero
,
BiFunction<? super T, ? super T, ? extends T>
the associative operator for the scan
operation
)

Implements io.vavr.collection.Set.scan.

Computes a prefix scan of the elements of the collection.

public <U> LinkedHashSet<U>
scanLeft(U
the initial value
zero
,
BiFunction<? super U, ? super T, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.Set.scanLeft.

Produces a collection containing cumulative results of applying the operator going left to right.

public <U> LinkedHashSet<U>
scanRight(U
the initial value
zero
,
BiFunction<? super T, ? super U, ? extends U>
the binary operator applied to the intermediate result and the element
operation
)

Implements io.vavr.collection.Set.scanRight.

Produces a collection containing cumulative results of applying the operator going right to left.

public Iterator<LinkedHashSet<T>>
slideBy(Function<? super T, ?>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.Set.slideBy.

Slides a non-overlapping window of a variable size over this Traversable.

public Iterator<LinkedHashSet<T>>
sliding(int
a positive window size
size
)

Implements io.vavr.collection.Set.sliding.

Slides a window of a specific size and step size 1 over this Traversable by calling sliding(int, int).

public Iterator<LinkedHashSet<T>>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Implements io.vavr.collection.Set.sliding.

Slides a window of a specific size and step size over this Traversable.

public Tuple2<LinkedHashSet<T>, LinkedHashSet<T>>
span(Predicate<? super T>
A predicate.
predicate
)

Implements io.vavr.collection.Set.span.

Returns a tuple where the first element is the longest prefix of elements that satisfy the given predicate and the second element is the remainder.

public String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public static <
Component type of the LinkedHashSet
T
>
LinkedHashSet<T>

Returns:

A LinkedHashSet consisting of elements f(0),f(1), ..., f(n - 1)
tabulate
(int
The number of elements in the LinkedHashSet
n
,
Function<? super Integer, ? extends T>
The Function computing element values
f
)

Returns a LinkedHashSet containing n values of a given Function f over a range of integer values from 0 to n - 1.

public LinkedHashSet<T>
tail()

Implements io.vavr.collection.Set.tail.

Drops the first element of a non-empty Traversable.

public Option<LinkedHashSet<T>>
tailOption()

Implements io.vavr.collection.Set.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

public LinkedHashSet<T>
take(int
The number of elements to take.
n
)

Implements io.vavr.collection.Set.take.

Takes the first n elements of this or all elements, if this length < n.

public LinkedHashSet<T>
takeRight(int
The number of elements to take.
n
)

Implements io.vavr.collection.Set.takeRight.

Takes the last n elements of this or all elements, if this length < n.

public LinkedHashSet<T>
takeUntil(Predicate<? super T>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.Set.takeUntil.

Takes elements until the predicate holds for the current element.

public LinkedHashSet<T>
takeWhile(Predicate<? super T>
A condition tested subsequently for the contained elements.
predicate
)

Implements io.vavr.collection.Set.takeWhile.

Takes elements while the predicate holds for the current element.

public LinkedHashSet<T>
toJavaSet()

Implements io.vavr.collection.Set.toJavaSet.

Converts this Vavr Set to a java.util.Set while preserving characteristics like insertion order (LinkedHashSet) and sort order (SortedSet).

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

public <
Type of transformation result
U
>
U

Returns:

An instance of type U
transform
(Function<? super LinkedHashSet<T>, ? extends U>
A transformation
f
)

Transforms this LinkedHashSet.

public LinkedHashSet<T>

Returns:

A new set that contains all distinct elements of this and elements set.
union
(Set<? extends T>
The set to form the union with.
elements
)

Implements io.vavr.collection.Set.union.

Adds all of the elements of elements to this set, replacing existing ones if they already present.

public <T1, T2> Tuple2<LinkedHashSet<T1>, LinkedHashSet<T2>>
unzip(Function<? super T, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.Set.unzip.

Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets.

public <T1, T2, T3> Tuple3<LinkedHashSet<T1>, LinkedHashSet<T2>, LinkedHashSet<T3>>
unzip3(Function<? super T, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs
unzipper
)

Implements io.vavr.collection.Set.unzip3.

Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets.

pack-priv static <T> LinkedHashSet<T>
private Object

Returns:

A SerializationProxy for this enclosing class.
writeReplace
()

writeReplace method for the serialization proxy pattern.

public <U> LinkedHashSet<Tuple2<T, U>>
zip(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
)

Implements io.vavr.collection.Set.zip.

Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs.

public <U> LinkedHashSet<Tuple2<T, U>>
zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair.
that
,
T
The element to be used to fill up the result if this traversable is shorter than that.
thisElem
,
U
The element to be used to fill up the result if that is shorter than this traversable.
thatElem
)

Implements io.vavr.collection.Set.zipAll.

Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs.

public <U, R> LinkedHashSet<R>
zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper.
that
,
BiFunction<? super T, ? super U, ? extends R>
a mapper.
mapper
)

Implements io.vavr.collection.Set.zipWith.

Returns a traversable formed from this traversable and another Iterable collection by mapping elements.

public LinkedHashSet<Tuple2<T, Integer>>
zipWithIndex()

Implements io.vavr.collection.Set.zipWithIndex.

Zips this traversable with its indices.

public <U> LinkedHashSet<U>
zipWithIndex(BiFunction<? super T, ? super Integer, ? extends U>
a mapper.
mapper
)

Implements io.vavr.collection.Set.zipWithIndex.

Zips this traversable with its indices by applying mapper provided.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait