DataList

class DataList<DataT>(initialData: DataT)

Represents a list of data items. Supports three operations:

  • add: Adds data to the end of the list

  • remove: Removes the given item from the list, returns current last element and indication if the removed element was last.

  • last: Returns last element in the list, or initialData if the list is empty.

This structure is NOT thread-safe. Synchronization should be performed externally.

Parameters

DataT

The type of data in the sequence.

Constructors

Link copied to clipboard
constructor(initialData: DataT)

Creates a DataList with the initial data item.

Types

Link copied to clipboard
class RemovedDataInfo<T>(val newLast: T, val wasLast: Boolean)

Functions

Link copied to clipboard
fun add(item: DataT)

Adds item to the end of the list

Link copied to clipboard
fun last(): DataT

Returns the last data item in the list. If the list is empty, it returns the initialData.

Link copied to clipboard

Removes item and returns last item along with the indication if the removed element was the last one.