Go to repository

Interface Compactable<A>

A Compactable is a data structure that changes over time, and incorporates the possibility to compact all changes, leaving the structure as if the current value was used at creation.

The operation compact can be used to set the current value as the initial one, forgetting all registered changes -- this is useful, for example, for memory saving. Also, information about all changes made since creation or the last compactation can be accessed using numAllChanges and allChanges.

interface Compactable<A> {
    allChanges(): A[];
    compact(): void;
    numAllChanges(): number;
}

Type Parameters

  • A

Implemented by

API

Returns the list of all changes. The first value is the initial one and the last one is the previous to the current one.

Returns A[]

Commit all changes, leaving only the last one as the current one, deleting all registered changes.

Returns void

Describe the number of all changes made to the value since the initial one was given (either at creation or after a save).

Returns number