Mutable Indexed Collection
Mutable indexed collection provides methods to modify its content based on element position
Def
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
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
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
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
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
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
Update many at position
Update many at position
Replaces elements starting at given position with stream values
- Source
- __.scala
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
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
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
Check if contains
Check if contains
Returns true if given element is contained by the implementing container
- Inherited from
- Contain
- Source
- Contain.scala
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
Replace everything
Replace everything
Discards all old elements and adds all provided elements
- Inherited from
- Mutable
- Source
- Mutable.scala