Idx.Mutable

trait Mutable[A] extends Idx[A] with Collection.Mutable[A] with Able.Contain[A]

Mutable Indexed Collection

Mutable indexed collection provides methods to modify its content based on element position

Companion
object
Source
__.scala
trait Able.Contain[A]
trait Able.Add[A]
trait Idx[A]
trait Collection[A]
trait Able.Size
trait Able.~[A]
class Object
trait Matchable
class Any

Def

@targetName("_addAllAt")
inline def ++=@(inline position: Int, inline v: ~[A]): Idx.Mutable[A]

Alias for addAllAt

Alias for addAllAt

Adds stream elements at given position

  // Generic example
  val x = ('A' <> 'F').~.toBuffer

  x ++=@ (4, 'e' <> 'g') ++=@ (1, ~~('b','c','d'))

  x.~.tp // Prints ~(A, b, c, d, B, C, D, e, f, g, E, F)
Source
__.scala
@targetName("_addAt")
inline def +=@(inline position: Int, inline v: A): Idx.Mutable[A]

Alias for addAt

Alias for addAt

Adds element at given position

  // Generic example
  val x = ('A' <> 'F').~.toBuffer

  x +=@ (3, 'd') +=@ (2, 'c') +=@ (1, 'b') +=@ (0, 'a')

  x.~.tp // Prints ~(a, A, b, B, c, C, d, D, E, F)
Source
__.scala
def add(v: A): Unit

Append element

Append element

Adds given element to the end of this Idx

Source
__.scala
override def addAll(v: ~[A]): Unit

Append all

Append all

Adds all stream values to the end of this Idx

Definition Classes
Source
__.scala
def addAllAt(position: Int, v: ~[A]): Unit

Add stream at position

Add stream at position

Adds stream elements at given position

  // Generic example
  val x = ('A' <> 'F').~.toBuffer

  x.addAllAt(4, 'e' <> 'g')
  x.addAllAt(1, ~~('b','c','d'))

  x.~.tp // Prints ~(A, b, c, d, B, C, D, e, f, g, E, F)
Source
__.scala
def addAt(position: Int, v: A): Unit

Add at position

Add at position

Adds element at given position

  // Generic example
  val x = ('A' <> 'F').~.toBuffer

  x.addAt(3, 'd')
  x.addAt(2, 'c')
  x.addAt(1, 'b')
  x.addAt(0, 'a')

  x.~.tp // Prints ~(a, A, b, B, c, C, d, D, E, F)
Source
__.scala
def clear: Unit
Source
__.scala
def remove(v: A): Int

Remove element

Remove element

Removes all Idx elements, which are equal to the given value

Returns count of removed elements, which can be 0, 1, or many

Source
__.scala
@targetName("remove_Range")
def remove_<>(range: <>): Unit

Remove range

Remove range

Removes elements at given range

 // Generic example
 val x = (0 <> 10).~.toBuffer

 x.remove(7 <> 8)
 x.remove(2 <> 4)

 x.~.tp // Prints ~(0, 1, 5, 6, 9, 10)
Source
__.scala
def removeAt(position: Int): Unit

Remove at position

Remove at position

Removes element at given position

 // Generic example
 val x = ('A' <> 'D').~.toBuffer

 x.remove(2)
 x.remove(1)

 x.~.tp // Prints ~(A, D)
Source
__.scala
def reposition(v: Permutation): Unit

Reorganizes elements

Reorganizes elements

Reorganizes elements according to the given permutation

  val im: Idx.Mutable[Int] = (0 <> 9).~.toBuffer

  val p = Idx.Permutation.pairs(3 -> 7, 7 -> 3, 4 -> 6, 6 -> 4)

  im.~.tp
  im.reposition(p)
  im.~.tp

  // Output
  ~(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  ~(0, 1, 2, 7, 6, 5, 4, 3, 8, 9)
Source
__.scala
def sort(using c: Ordering[A]): Unit

Sort elements

Sort elements

Sorts elements in this container

Source
__.scala
def updateAllAt(position: Int, s: ~[A]): Unit

Update many at position

Update many at position

Replaces elements starting at given position with stream values

Source
__.scala
def updateAt(position: Int, s: A): Unit

Update at position

Update at position

Replaces element at given position with given value

  val im: Idx.Mutable[Int] = (0 <> 7).~.toBuffer

  im.updateAt(7, 777)
  im.updateAt(3, 333)

  im.~.tp // Prints ~(0, 1, 2, 333, 4, 5, 6, 777)

  // The same can be done with Scala symplified syntax

  im(7) = 777
  im(3) = 333

Source
__.scala

Inherited

@targetName("stream")
def ~: ~[A]

Returns a Stream of all elements

Returns a Stream of all elements

The element order is same as in the Idx itself

  val l: Idx[Char] = ('a' <> 'g').~.><

  l.~.tp  // Prints ~(a, b, c, d, e, f, g)
Inherited from
Idx
Source
__.scala
@targetName("addAll")
inline def ++=(inline v: ~[A]): Idx.Mutable[A]

Alias for addAll

Alias for addAll

Calls addAll and returns container

 // Generic example
 val x =  Idx.M(1, 2, 3)

 x ++= (4 <> 6) ++= Stream(7, 8, 9)

 x.~.tp // ~~(1, 2, 3, 4, 5, 6, 7, 8, 9)
Inherited from
Add
Source
Add.scala
@targetName("add")
inline def +=(inline v: A | Opt[A]): Idx.Mutable[A]

Alias for add

Alias for add

Calls add and returns container

 // Generic example
 val x =  Idx.M(1, 2, 3)

  x += 4 += 5 += 6

  x.~.tp // Prints ~(1, 2, 3, 4, 5, 6)
Inherited from
Add
Source
Add.scala
@targetName("_removeAll")
inline def --=(inline v: ~[A]): Idx.Mutable[A]

Alias for removeAll

Alias for removeAll

Removes all collection elements, which are equal to those in given stream

Returns count of removed elements, which can be 0, 1, or many

Inherited from
Mutable
Source
Mutable.scala
@targetName("_remove")
inline def -=(inline v: A): Idx.Mutable[A]

Alias for remove

Alias for remove

Removes all collection elements, which are equal to the given value

Returns count of removed elements, which can be 0, 1, or many

Inherited from
Mutable
Source
Mutable.scala
@targetName("add_Opt")
def add_?(o: Opt[A]): Unit

Optional add

Optional add

Adds element if option has value, does nothing for void option

Inherited from
Add
Source
Add.scala
def apply(i: Int): A

Returns element at specified position

Returns element at specified position

 val idx: Idx[Char] = ('A' <> 'Z').~.><

 idx(1).tp // Prints: B

 idx(4).tp // Prints: E
Inherited from
Idx
Source
__.scala
def contains(v: A): Boolean

Check if contains

Check if contains

Returns true if given element is contained by the implementing container

Inherited from
Contain
Source
Contain.scala
def isEmpty: Boolean
Inherited from
Size
Source
Size.scala
def removeAll(v: ~[A]): Int

Remove all streamed

Remove all streamed

Removes all collection elements, which are equal to those in given stream

Returns count of removed elements, which can be 0, 1, or many

Inherited from
Mutable
Source
Mutable.scala
def replaceAll(v: ~[A]): Unit

Replace everything

Replace everything

Discards all old elements and adds all provided elements

Inherited from
Mutable
Source
Mutable.scala
def size: Int
Inherited from
Idx
Source
__.scala

Extension

def removeFor: Int
Extension method from Mutable
Source
__.scala
def sortBy: Unit
Extension method from Mutable

Sort by property

Sort by property

Sorts elements in this container based on given property map

Source
__.scala
def sortBy: Unit
Extension method from Mutable

Sort by two properties

Sort by two properties

Sorts elements in this container based on given two properties

Source
__.scala
def sortBy: Unit
Extension method from Mutable

Sort by three properties

Sort by three properties

Sorts elements in this container based on given three properties

Source
__.scala
def sortReversed: Unit
Extension method from Mutable

Sort in reverse

Sort in reverse

Sorts elements in this container in reverse

Source
__.scala
@targetName("twoWay_View")
Extension method from Mutable
Source
__.scala
@targetName("twoWay_View")
Extension method from Mutable
Source
__.scala
def updateFor: Int
Extension method from Mutable
Source
__.scala