tinyscalautils.collection

Members list

Type members

Classlikes

object ArrayList

Attributes

Source
lists.scala
Supertypes
class Object
trait Matchable
class Any
Self type
ArrayList.type
object HashSet

Attributes

Source
sets.scala
Supertypes
class Object
trait Matchable
class Any
Self type
HashSet.type
object JavaList

Attributes

Source
lists.scala
Supertypes
class Object
trait Matchable
class Any
Self type
JavaList.type
trait JavaListFactory[C <: (List)]

Attributes

Companion
object
Source
lists.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object factory
object factory

Attributes

Companion
trait
Source
lists.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object JavaSet

Attributes

Source
sets.scala
Supertypes
class Object
trait Matchable
class Any
Self type
JavaSet.type
trait JavaSetFactory[C <: (Set)]

Attributes

Companion
object
Source
sets.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object factory
object factory

Attributes

Companion
trait
Source
sets.scala
Supertypes
class Object
trait Matchable
class Any
Self type
object LinkedList

Attributes

Source
lists.scala
Supertypes
class Object
trait Matchable
class Any
Self type
LinkedList.type
object TreeSet

Attributes

Source
sets.scala
Supertypes
class Object
trait Matchable
class Any
Self type
TreeSet.type

Extensions

Extensions

extension [A](col: Collection[A])
inline def nonEmpty: Boolean

Adds a nonEmpty method on Java collections.

Adds a nonEmpty method on Java collections.

Attributes

Since

1.2

Source
nonEmpty.scala
extension [A](collection: IterableOnce[A])

True if all the collection's elements are distinct.

True if all the collection's elements are distinct.

Note that this is true of an empty collection.

Attributes

Since

1.7

Source
allDistinct.scala
extension [A](collection: Iterable[A])
def pickOne(using rand: Random): A

Picks one element at random.

Picks one element at random.

This should not be used in a loop; use randomly instead.

The collection is assumed non-emtpy.

Attributes

Throws
NoSuchElementException

if the collection is empty.

Since

1.0

Source
pickOne.scala
def pickOneOption(using Random): Option[A]

Picks one element at random.

Picks one element at random.

This should not be used in a loop; use randomly instead.

Returns None if the collection is empty.

Attributes

Since

1.0

Source
pickOne.scala
extension [A](element: A)
infix def in(collection: Iterable[A]): Boolean

Reverses the order of contains.

Reverses the order of contains.

value in collection replaces collection contains value.

Attributes

Since

1.0

Source
in.scala
extension [A](elements: IterableOnce[A])(using rand: Random)
def randomly: Iterator[A]

An iterator that produces the elements of a collection in a random (uniform) order.

An iterator that produces the elements of a collection in a random (uniform) order.

If the collection is empty, the iterator is empty; otherwise, it is infinite.

This method iterates over the entire collection and is not thread-safe in general. However, the iterator that is returned relies on its own copy and is thread-safe if the random number generator is thread-safe.

Attributes

Since

1.0

Source
randomly.scala
def shuffle[C](using BuildFrom[elements.type, A, C]): C

A convenient way to invoke Random.shuffle in a pipeline.

A convenient way to invoke Random.shuffle in a pipeline.

Attributes

Since

1.0

Source
randomly.scala
extension [A](iterable: Iterable[A])
def circular: Iterator[A]

An iterator that repeats the elements of the iterable in a circular way.

An iterator that repeats the elements of the iterable in a circular way.

For instance,

List(A,B,C).circular

is the infinite iterator A,B,C,A,B,C,A,B,....

The iterator is empty if the source is empty.

Attributes

Since

1.0

Source
circular.scala
extension [A](iterable: IterableOnce[A])
def last: A

The last element of the collection, if any.

The last element of the collection, if any.

Attributes

Throws
NoSuchElementException

if the collection is empty.

Since

1.5.0

Source
last.scala
def lastOption: Option[A]

The last element of the collection, if any.

The last element of the collection, if any.

Attributes

Since

1.5.0

Source
last.scala
extension [A, CC[_]](self: SeqOps[A, CC, CC[A]])
def sortedInReverse[B >: A](using evidence$1: Ordering[B]): CC[A]

Sorted according to implicit order, but in reverse.

Sorted according to implicit order, but in reverse.

Attributes

Source
sorted.scala
extension [A, CC[_]](seq: SeqOps[A, CC, CC[A]])
def deleted(i: Int): CC[A]

A new sequence in which element at position i has been deleted. If i is not a valid index, no exception is thrown and the sequence is returned unchanged (usually as the same instance).

A new sequence in which element at position i has been deleted. If i is not a valid index, no exception is thrown and the sequence is returned unchanged (usually as the same instance).

Attributes

Since

1.5.0

Source
deleted.scala
def updatedWith[B >: A](i: Int)(f: A => Option[B]): CC[B]

A new sequence in which element at position i has been replaced with a new value, if any. The new value is computed as f(seq(i)). If it doesn't produce a replacement value, the element at position i is simply removed. If i is not a valid index, no exception is thrown and the sequence is returned unchanged (usually as the same instance).

A new sequence in which element at position i has been replaced with a new value, if any. The new value is computed as f(seq(i)). If it doesn't produce a replacement value, the element at position i is simply removed. If i is not a valid index, no exception is thrown and the sequence is returned unchanged (usually as the same instance).

Attributes

Since

1.5.0

Source
deleted.scala

Deprecated extensions

extension [A](queue: Queue[A])
def peekOption: Option[A]

Attributes

Deprecated
[Since version 1.3]
Source
Queue.scala
def pollOption(): Option[A]

Attributes

Deprecated
[Since version 1.3]
Source
Queue.scala