<commit_before>import { Option } from './platform-utils';

export interface LinkedListNode {
  next: Option<LinkedListNode>;
  prev: Option<LinkedListNode>;
}

export class ListNode<T> implements LinkedListNode {
  public next: Option<ListNode<T>> = null;
  public prev: Option<ListNode<T>> = null;
  public value: T;

  constructor(value: T) {
    this.value = value;
  }
}

// we are unable to express the constraint that T's .prev and .next are
// themselves T. However, it will always be true, so trust us.
type trust = any;

export class LinkedList<T extends LinkedListNode> implements Slice<T> {
  private _head: Option<T>;
  private _tail: Option<T>;

  constructor() {
    this.clear();
  }

  head(): Option<T> {
    return this._head;
  }

  tail(): Option<T> {
    return this._tail;
  }

  clear() {
    this._head = this._tail = null;
  }

  toArray(): T[] {
    let out: T[] = [];
    this.forEachNode(n => out.push(n));
    return out;
  }

  nextNode(node: T): T {
    return node.next as trust;
  }
<commit_msg>fix TS strictness errors in @glimmer/util<commit_after>import { Option } from './platform-utils';

export interface LinkedListNode {
  next: Option<LinkedListNode>;
  prev: Option<LinkedListNode>;
}

export class ListNode<T> implements LinkedListNode {
  public next: Option<ListNode<T>> = null;
  public prev: Option<ListNode<T>> = null;
  public value: T;

  constructor(value: T) {
    this.value = value;
  }
}

// we are unable to express the constraint that T's .prev and .next are
// themselves T. However, it will always be true, so trust us.
type trust = any;

export class LinkedList<T extends LinkedListNode> implements Slice<T> {
  private _head!: Option<T>;
  private _tail!: Option<T>;

  constructor() {
    this.clear();
  }

  head(): Option<T> {
    return this._head;
  }

  tail(): Option<T> {
    return this._tail;
  }

  clear() {
    this._head = this._tail = null;
  }

  toArray(): T[] {
    let out: T[] = [];
    this.forEachNode(n => out.push(n));
    return out;
  }

  nextNode(node: T): T {
    return node.next as trust;
  }

{'fraction_non_alphanumeric': 0.13806327900287632, 'fraction_numerical': 0.0, 'mean_word_length': 3.25050916496945, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7236177', 'n_tokens_mistral': 708, 'n_tokens_neox': 691, 'n_words': 207}