// ets_tracing: off
import "../../Operator";
export class LinkedListNode {
  constructor(value, next = null) {
    this.value = value;
    this.next = next;
  }

}
export class LinkedList {
  constructor(head = null, tail = null) {
    this.head = head;
    this.tail = tail;
    this.head = null;
    this.tail = null;
  }

  empty() {
    return this.head === null;
  }

  prepend(value) {
    const newNode = new LinkedListNode(value, this.head);
    this.head = newNode;

    if (!this.tail) {
      this.tail = newNode;
    }

    return this;
  }

  append(value) {
    const newNode = new LinkedListNode(value);

    if (!this.head) {
      this.head = newNode;
      this.tail = newNode;
      return this;
    } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion


    this.tail.next = newNode;
    this.tail = newNode;
    return this;
  }

  deleteHead() {
    if (!this.head) {
      return null;
    }

    const deletedHead = this.head;

    if (this.head.next) {
      this.head = this.head.next;
    } else {
      this.head = null;
      this.tail = null;
    }

    return deletedHead;
  }

}
//# sourceMappingURL=index.js.map