Idx.ObservableMutable.X.Abstract
- Source
- X.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 stream at position
Add stream at position
Adds stream elements
at given position
// Generic example
val x = ('A' <> 'F').stream.toBuffer
x.addAllAt(4, 'e' <> 'g')
x.addAllAt(1, Stream('b','c','d'))
x.stream.tp // Prints Stream(A, b, c, d, B, C, D, e, f, g, E, F)
Single transaction interface
Single transaction interface
Allows to make multiple changes to the underlying collection, generating a single change event
- Inherited from
- ObservableMutable
- Source
- __.scala
On element add
On element add
Subscribes given function to element add event
val co: Collection.ObservableMutable[Int] = Collection.OM[Int]()
co.onAdd("Added: "+ _ tp())
co ++= 1 <> 3
// Output
Added: 1
Added: 2
Added: 3
- Definition Classes
- Inherited from
- Observable
- Source
- __.scala
On event
On event
Subscribes given function to all element changes
val idx: Idx.OM[Int] = Idx.OM[Int]()
idx.onChange(_.stream.tp)
idx ++= 1 <> 5
idx(2) = 22
idx.removeRange(3 <> 4)
idx.stream.tp
// Output
Stream(IdxChange{type=Add,range=0 <> 4,items=[1,2,3,4,5]})
Stream(IdxChange{type=Update,range=2 <> 2,items=22,oldItems=3})
Stream(IdxChange{type=Remove,range=3 <> 4,items=[4,5]})
Stream(1, 2, 22)
- Inherited from
- Observable
- Source
- __.scala
On element remove
On element remove
Subscribes given function to element remove event
val co: Collection.ObservableMutable[Int] = Collection.OM[Int]()
co.onRemove("Removed: "+ _ tp())
co ++= 1 <> 10
co --= 5 <> 7
// Output
Removed: 7
Removed: 6
Removed: 5
- Definition Classes
- Inherited from
- Observable
- Source
- __.scala
Creates a refresh event
Creates a refresh event
Refresh event is an Update event for specified elements, where old and new values are the same.
Supposedly, the elements themself are mutable and their representation has to be "refreshed"
- Inherited from
- ObservableMutable
- Source
- __.scala
Creates a refresh event for range of elements
Creates a refresh event for range of elements
Refresh event is an Update event for specified elements, where old and new values are the same.
Supposedly, the elements themself are mutable and their representation has to be "refreshed"
- Inherited from
- ObservableMutable
- 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
- Definition Classes
- Inherited from
- ObservableMutable
- 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