Guest User

Untitled

a guest
Mar 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. /** Defines an ADT for an ordered collection of elements with zero-based indexing.
  2. * @abstract
  3. */
  4.  
  5. class List { // eslint-disable-line no-unused-vars
  6. /** Creates a new, empty List object.
  7. * @hideconstructor
  8. * @abstract
  9. */
  10. constructor() {
  11. if (this.constructor === List) {
  12. throw new TypeError('Cannot create objects of abstract class List.');
  13. }
  14. }
  15.  
  16. /** Returns the length of this List.
  17. * @returns {number} The number of elements stored in this List.
  18. * @public
  19. * @abstract
  20. */
  21. length() {
  22. throw new TypeError(`Class '${this.constructor.name}' is a subclass of 'List', and must implement abstract method '${((new Error()).stack.split('@', 1))[0]}'.`);
  23. }
  24.  
  25. /** Returns an element of this List by index.
Add Comment
Please, Sign In to add comment