dl-doubly-linked-list-ts
Version:
A Typescript library for doubly linked-list implementation.
41 lines (36 loc) • 990 B
text/typescript
/**
* Node implementation class. A node is a vertex in the list which contains data and pointers to the next node and previous node.
*/
export class DLNode<T> {
/**
* The data contained in the node.
*/
private _data : T | null = null;
/**
* The edge or pointer to the next node.
*/
private _next : DLNode<T> | null = null;
/**
* The edge or pointer to the previous node.
*/
private _previous : DLNode<T> | null = null;
constructor() {}
get data() : T | null {
return this._data;
}
get next() : DLNode<T> | null {
return this._next;
}
get previous() : DLNode<T> | null {
return this._previous;
}
set data( data : T | null ) {
this._data = data;
}
set next( next : DLNode<T> | null ) {
this._next = next;
}
set previous( previous : DLNode<T> | null ) {
this._previous = previous;
}
}