Package io.vavr.collection
Class Stream.Cons<T>
- java.lang.Object
-
- io.vavr.collection.Stream<T>
-
- io.vavr.collection.Stream.Cons<T>
-
- Type Parameters:
T
- Component type of the Stream.
- All Implemented Interfaces:
Foldable<T>
,LinearSeq<T>
,Seq<T>
,Traversable<T>
,Function1<java.lang.Integer,T>
,Iterable<T>
,PartialFunction<java.lang.Integer,T>
,Value<T>
,java.io.Serializable
,java.lang.Iterable<T>
,java.util.function.Function<java.lang.Integer,T>
@Deprecated public abstract static class Stream.Cons<T> extends Stream<T>
Deprecated.will be removed from the public APINon-emptyStream
, consisting of ahead
, andtail
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.vavr.collection.Stream
Stream.Cons<T>, Stream.Empty<T>
-
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object o)
Deprecated.In Vavr there are four basic classes of collections: Seq (sequential elements) Set (distinct elements) Map (indexed elements) Multimap (indexed collections) Two collection instances of these classes are equal if and only if both collections belong to the same basic collection class (Seq, Set, Map or Multimap) contain the same elements have the same element order, if the collections are of type Seq Two Map/Multimap elements, resp.int
hashCode()
Deprecated.Returns the hash code of this collection.T
head()
Deprecated.Returns the first element of a non-empty Traversable.boolean
isEmpty()
Deprecated.Checks if this Traversable is empty.Iterator<T>
iterator()
Deprecated.An iterator by means of head() and tail().java.lang.String
toString()
Deprecated.Clarifies that values have a proper toString() method implemented.-
Methods inherited from class io.vavr.collection.Stream
append, appendAll, appendSelf, asJava, asJava, asJavaMutable, asJavaMutable, collect, collector, combinations, combinations, concat, concat, cons, continually, continually, crossProduct, cycle, cycle, distinct, distinctBy, distinctBy, drop, dropRight, dropRightUntil, dropRightWhile, dropUntil, dropWhile, empty, extend, extend, extend, fill, fill, filter, filterNot, flatMap, from, from, from, from, get, groupBy, grouped, hasDefiniteSize, indexOf, init, initOption, insert, insertAll, intersperse, isAsync, isLazy, isTraversableAgain, iterate, iterate, last, lastIndexOf, leftPadTo, length, map, narrow, of, of, ofAll, ofAll, ofAll, ofAll, ofAll, ofAll, ofAll, ofAll, ofAll, ofAll, orElse, orElse, padTo, partition, patch, peek, permutations, prepend, prependAll, range, range, range, rangeBy, rangeBy, rangeBy, rangeBy, rangeClosed, rangeClosed, rangeClosed, rangeClosedBy, rangeClosedBy, rangeClosedBy, rangeClosedBy, reject, remove, removeAll, removeAll, removeAll, removeAt, removeFirst, removeLast, replace, replaceAll, retainAll, reverse, rotateLeft, rotateRight, scan, scanLeft, scanRight, shuffle, shuffle, slice, slideBy, sliding, sliding, sortBy, sortBy, sorted, sorted, span, splitAt, splitAt, splitAtInclusive, stringPrefix, subSequence, subSequence, tabulate, tail, tailOption, take, takeRight, takeRightUntil, takeRightWhile, takeUntil, takeWhile, transform, transpose, unfold, unfoldLeft, unfoldRight, unzip, unzip3, update, update, zip, zipAll, zipWith, zipWithIndex, zipWithIndex
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.vavr.Function1
andThen, arity, compose, curried, isMemoized, memoized, partial, reversed, tupled
-
Methods inherited from interface io.vavr.collection.LinearSeq
asPartialFunction, indexOfSlice, indexWhere, isDefinedAt, lastIndexOfSlice, lastIndexWhere, reverseIterator, search, search, segmentLength
-
Methods inherited from interface io.vavr.collection.Seq
apply, containsSlice, crossProduct, crossProduct, endsWith, foldRight, indexOf, indexOfOption, indexOfOption, indexOfSlice, indexOfSliceOption, indexOfSliceOption, indexWhere, indexWhereOption, indexWhereOption, isSequential, iterator, lastIndexOf, lastIndexOfOption, lastIndexOfOption, lastIndexOfSlice, lastIndexOfSliceOption, lastIndexOfSliceOption, lastIndexWhere, lastIndexWhereOption, lastIndexWhereOption, lift, prefixLength, startsWith, startsWith, withDefault, withDefaultValue
-
Methods inherited from interface io.vavr.collection.Traversable
arrangeBy, average, containsAll, count, existsUnique, find, findLast, fold, foldLeft, forEachWithIndex, get, headOption, isDistinct, isOrdered, isSingleValued, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, nonEmpty, product, reduce, reduceLeft, reduceLeftOption, reduceOption, reduceRight, reduceRightOption, single, singleOption, size, spliterator, sum
-
Methods inherited from interface io.vavr.Value
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, out, out, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
-
-
-
-
Method Detail
-
head
public T head()
Deprecated.Description copied from interface:Traversable
Returns the first element of a non-empty Traversable.- Returns:
- The first element of this Traversable.
-
isEmpty
public boolean isEmpty()
Deprecated.Description copied from interface:Traversable
Checks if this Traversable is empty.- Returns:
- true, if this Traversable contains no elements, false otherwise.
-
iterator
public Iterator<T> iterator()
Deprecated.Description copied from interface:Traversable
An iterator by means of head() and tail(). Subclasses may want to override this method.- Returns:
- A new Iterator of this Traversable elements.
-
equals
public boolean equals(java.lang.Object o)
Deprecated.Description copied from interface:Traversable
In Vavr there are four basic classes of collections:- Seq (sequential elements)
- Set (distinct elements)
- Map (indexed elements)
- Multimap (indexed collections)
- belong to the same basic collection class (Seq, Set, Map or Multimap)
- contain the same elements
- have the same element order, if the collections are of type Seq
Notes:
- No collection instance equals null, e.g. Queue(1) not equals null.
- Nulls are allowed and handled as expected, e.g. List(null, 1) equals Stream(null, 1) and HashMap((null, 1)) equals LinkedHashMap((null, 1)).
- The element order is taken into account for Seq only. E.g. List(null, 1) not equals Stream(1, null) and HashMap((null, 1), ("a", null)) equals LinkedHashMap(("a", null), (null, 1)). The reason is, that we do not know which implementations we compare when having two instances of type Map, Multimap or Set (see Liskov Substitution Principle).
- Other collection classes are equal if their types are equal and their elements are equal (in iteration order).
- Iterator equality is defined to be object reference equality.
-
hashCode
public int hashCode()
Deprecated.Description copied from interface:Traversable
Returns the hash code of this collection.
We distinguish between two types of hashes, those for collections with predictable iteration order (like Seq) and those with arbitrary iteration order (like Set, Map and Multimap).
In all cases the hash of an empty collection is defined to be 1.
Collections with predictable iteration order are hashed as follows:
Collections with arbitrary iteration order are hashed in a way such that the hash of a fixed number of elements is independent of their iteration order.int hash = 1; for (T t : this) { hash = hash * 31 + Objects.hashCode(t); }
Please note that the particular hashing algorithms may change in a future version of Vavr.int hash = 1; for (T t : this) { hash += Objects.hashCode(t); }
Generally, hash codes of collections aren't cached in Vavr (opposed to the size/length). Storing hash codes in order to reduce the time complexity would increase the memory footprint. Persistent collections are built upon tree structures, it allows us to implement efficient memory sharing. A drawback of tree structures is that they make it necessary to store collection attributes at each tree node (read: element).
The computation of the hash code is linear in time, i.e. O(n). If the hash code of a collection is re-calculated often, e.g. when using a List as HashMap key, we might want to cache the hash code. This can be achieved by simply using a wrapper class, which is not included in Vavr but could be implemented like this:public final class Hashed<K> { private final K key; private final Lazy<Integer> hashCode; public Hashed(K key) { this.key = key; this.hashCode = Lazy.of(() -> Objects.hashCode(key)); } public K key() { return key; } @Override public boolean equals(Object o) { if (o == key) { return true; } else if (key != null && o instanceof Hashed) { final Hashed that = (Hashed) o; return key.equals(that.key); } else { return false; } } @Override public int hashCode() { return hashCode.get(); } @Override public String toString() { return "Hashed(" + (key == null ? "null" : key.toString()) + ")"; } }
-
toString
public java.lang.String toString()
Deprecated.Description copied from interface:Value
Clarifies that values have a proper toString() method implemented.See Object.toString().
-
-