An abstraction of the list data structure.
Install from NPM with
$ npm install --save @jsdsl/abstract-list
The abstract class included in this package serves as a standardizing basis for a handful of other packages that implement list and list-like data structures, and is therefore not intended to be used alone.
Please refer to the documentation of the package implementing this package's abstract class for (hopefully) more useful information.
Adds an element to this list.
Parameters:
- element The element to add to this list.
Returns Void.
public abstract add(element: E): void;
Adds multiple elements to this list.
Parameters:
- elements The elements to add to this list.
Returns Void.
public addAll(elements: E[]): void { ... }
Returns the element at the specified index, or undefined if the index was out-of-bounds.
Parameters:
- index The index from which to retrieve an element.
Returns The element at the specified index, or undefined if the index was out-of-bounds.
public abstract get(index: number): E | undefined;
Removes the specified element from this list.
Parameters:
- elements The element to remove from this list.
Returns Void.
public abstract remove(element: E): void;
Returns the number of elements contained in this list.
Parameters:
- None
Returns The number of elements contained in this list.
public abstract size(): number;
Returns true if the provided element is contained in this list.
Parameters:
- elements The element to check this list for.
Returns true if the provided element is contained in this list.
public abstract contains(element: E): boolean;
Returns true if this list contains no elements.
Parameters:
- None
Returns true if this list contains no elements.
public isEmpty(): boolean { ... }
Removes all elements from this list, rendering the list empty.
Parameters:
- None
Returns Void.
public abstract clear(): void;
Returns an iterator over the elements of this list.
Parameters:
- None
Returns An iterator over the elements of this list.
See IIterator
public abstract iterator(): IIterator<E>;
Returns this list represented as an array of its elements.
Parameters:
- None
Returns This list represented as an array of its elements.
public abstract toArray(): E[];
@jsdsl/abstract-list is made available under the GNU General Public License v3.
Copyright (C) 2019 Trevor Sears