MutableSelection

class MutableSelection<K> : Selection


Subclass of Selection exposing public support for mutating the underlying selection data. This is useful for clients of SelectionTracker that wish to manipulate a copy of selection data obtained via copySelection.

While the Selection class is not intrinsically immutable, it is not mutable by non-library code. Furthermore the value returned from getSelection is a live view of the underlying selection, mutable by the library itself.

MutableSelection allows clients to obtain a mutable copy of the Selection state held by the selection library. This is useful in situations where a stable snapshot of the selection is required.

Example

MutableSelection snapshot = new MutableSelection();
selectionTracker.copySelection(snapshot);

// Clear the user visible selection.
selectionTracker.clearSelection();
// tracker.getSelection().isEmpty() will be true.
// shapshot has a copy of the previous selection.
Parameters
<K>

Selection key type. @see StorageStrategy for supported types.

See also
Selection

Summary

Public constructors

Public functions

Boolean
add(key: K)

Adds a new item to the primary selection.

Unit

Clears the primary selection.

Unit
copyFrom(source: Selection<K!>)

Clones primary and provisional selection from supplied Selection.

Boolean
remove(key: K)

Removes an item from the primary selection.

Inherited functions

From java.lang.Iterable
Unit
forEach(action: Consumer<Any!>!)
abstract (Mutable)Iterator<T!>!
Spliterator<T!>!
From androidx.recyclerview.selection.Selection
Boolean
contains(key: K?)
Boolean
equals(other: Any!)
Int
Boolean
(Mutable)Iterator<K!>

Returns an Iterator that iterators over the selection, *excluding* any provisional selection.

Int
String!

Public constructors

MutableSelection

Added in 1.0.0
MutableSelection()

Public functions

add

Added in 1.0.0
fun add(key: K): Boolean

Adds a new item to the primary selection.

Returns
Boolean

true if the operation resulted in a modification to the selection.

clear

Added in 1.0.0
fun clear(): Unit

Clears the primary selection. The provisional selection, if any, is unaffected.

copyFrom

Added in 1.0.0
fun copyFrom(source: Selection<K!>): Unit

Clones primary and provisional selection from supplied Selection. Does not copy active range data.

remove

Added in 1.0.0
fun remove(key: K): Boolean

Removes an item from the primary selection.

Returns
Boolean

true if the operation resulted in a modification to the selection.