export declare class Node { item: Item; next: Node; } /** * The Bag class represents a bag (or multiset) of * generic items. It supports insertion and iterating over the * items in arbitrary order. *

* This implementation uses a singly linked list with a static nested class Node. * See {@link LinkedBag} for the version from the * textbook that uses a non-static nested class. * See {@link ResizingArrayBag} for a version that uses a resizing array. * The add, isEmpty, and size operations * take constant time. Iteration takes time proportional to the number of items. *

* For additional documentation, see Section 1.3 of * Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. * * @param the generic type of an item in this bag */ export default class Bag implements Iterable { private first; private n; private modCount; /** * Initializes an empty bag. */ constructor(); /** * Returns true if this bag is empty. * * @return `true` if this bag is empty; * `false` otherwise */ isEmpty(): boolean; /** * Returns the number of items in this bag. * * @return the number of items in this bag */ size(): number; /** * Adds the item to this bag. * * @param item the item to add to this bag */ add(item: Item): void; /** * Returns an iterator that iterates over the items in this bag in arbitrary order. * * @return an iterator that iterates over the items in this bag in arbitrary order */ [Symbol.iterator](): { next(): IteratorResult; }; /** * Returns a string representation of this queue. * * @return the sequence of items in FIFO order, separated by spaces */ toString(): string; }