Value Buffer
Buffer is the default implementation of Mutable Indexed Collection
Buffer is an abstract class with concrete implementations: AnyRef.G.Buffer, Byte.G.Buffer, Int.G.Buffer, etc.
- Source
- __.scala
Def
Alias for removeAll
Alias for removeAll
Removes all collection elements, which are equal to those in given stream
Returns the collection itself
- Inherited from
- Mutable
- Source
- Mutable.scala
Alias for remove
Alias for remove
Removes all collection elements, which are equal to the given value
Returns the collection itself
- Inherited from
- Mutable
- Source
- Mutable.scala
Add array elements
Add array elements
Programms are expected to pass even private sensitive arrays, because this method is final and can be exemined not to abuse the trust
The given arguments specify range of elements to be added.
Whenever possible the adding will be done with bulk copy from given array to buffer array
- Source
- __.scala
Check if contains
Check if contains
Returns true if given element is contained by the implementing container
- Inherited from
- Contain
- Source
- Contain.scala
Process all elements
Process all elements
Applies given function to each Buffer element.
This method is more eficient than Stream foreach.
- Source
- __.scala
Pack Buffer elements
Pack Buffer elements
Both Buffer and Pack are mostly Array based, so the direct convertions between them are very efficient
- Source
- __.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
Remove range
Remove range
Removes elements at given range
val x = (0 <> 10).stream.toBuffer
x.remove(7 <> 8)
x.remove(2 <> 4)
x.stream.tp // Prints Stream(0, 1, 5, 6, 9, 10)
- Source
- __.scala
Replace everything
Replace everything
Discards all old elements and adds all provided elements
- Inherited from
- Mutable
- Source
- Mutable.scala
Reorganizes elements
Reorganizes elements
Reorganizes elements according to the given permutation
val im: Idx.Mutable[Int] = (0 <> 9).stream.toBuffer
val p = Idx.Permutation.pairs(3 -> 7, 7 -> 3, 4 -> 6, 6 -> 4)
im.stream.tp
im.reposition(p)
im.stream.tp
// Output
Stream(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Stream(0, 1, 2, 7, 6, 5, 4, 3, 8, 9)
Update at position
Update at position
Replaces element at given position with given value
val im: Idx.Mutable[Int] = (0 <> 7).stream.toBuffer
im.updateAt(7, 777)
im.updateAt(3, 333)
im.stream.tp // Prints Stream(0, 1, 2, 333, 4, 5, 6, 777)
// The same can be done with Scala symplified syntax
im(7) = 777
im(3) = 333