If you find this useful, please consider supporting my work with a donation.
- There is a
[Symbol.iterator]method so each instance is iterable.
sizegetter property instead of a
lengthdata property to indicate that the size of the list is dynamically counted rather than stored.
- Defining a
get()when no such index exists.
Use CommonJS to get access to the
const CircularDoublyLinkedList = ;
Each instance of
CircularDoublyLinkedList has the following properties and methods:
const list = ;// add an item to the endlist;// insert an itemlist;list;// get the value at an indexlet value = list;// get the number of itemslet count = listsize;// get the index of a valuelet index = list;// convert to an array using iteratorslet array1 = ...list;let array2 = ...list;// create a circular iterator to keep iterating over valuesconst iterator = list;// convert to an array in reverse order using an iteratorlet array3 = ...list;// remove an item at the given index and return the data that was removedlet data = list;// remove all itemslistclear;
Note on Code Style
Issues and Pull Requests
As this is part of series of tutorials I'm writing, only bug fixes will be accepted. No new functionality will be added to this module.