All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fitnesse.wikitext.parser.SymbolStream Maven / Gradle / Ivy

There is a newer version: 20241026
Show newest version
package fitnesse.wikitext.parser;

import java.util.LinkedList;

public class SymbolStream {
    public SymbolStream() {
        symbols = new LinkedList<>();
    }

    public SymbolStream(SymbolStream other) {
        symbols = new LinkedList<>(other.symbols);
    }

    public Symbol get(int position) {
        return symbols.size() <= position ? Symbol.emptySymbol : symbols.get(position);
    }

    public void add(Symbol value)  {
        symbols.addFirst(value);
        if (symbols.size() > streamCapacity) symbols.removeLast();
    }

    public boolean isEnd() { return symbols.isEmpty() || symbols.getFirst() == Symbol.emptySymbol; }

    private static final int streamCapacity = 3;

    private LinkedList symbols;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy