Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** Defines an ADT for an ordered collection of elements with zero-based indexing.
- * @abstract
- */
- class List { // eslint-disable-line no-unused-vars
- /** Creates a new, empty List object.
- * @hideconstructor
- * @abstract
- */
- constructor() {
- if (this.constructor === List) {
- throw new TypeError('Cannot create objects of abstract class List.');
- }
- }
- /** Returns the length of this List.
- * @returns {number} The number of elements stored in this List.
- * @public
- * @abstract
- */
- length() {
- throw new TypeError(`Class '${this.constructor.name}' is a subclass of 'List', and must implement abstract method '${((new Error()).stack.split('@', 1))[0]}'.`);
- }
- /** Returns an element of this List by index.
Add Comment
Please, Sign In to add comment