/** * Returns a shallow clone of this instance (the underlying ints are * <b>not</b> copied and will be shared by both the returned object and this * object. * * @see #deepCopyOf */ @Override public IntsRef clone() { return new IntsRef(ints, offset, length); }
/** Build a new {@link CharsRef} that has the same content as this builder. */ public IntsRef toIntsRef() { return IntsRef.deepCopyOf(get()); }
@Override public boolean equals(Object other) { if (other == null) { return false; } if (other instanceof IntsRef) { return this.intsEquals((IntsRef) other); } return false; }
@Override public int compare(FSTPath<T> a, FSTPath<T> b) { int cmp = comparator.compare(a.output, b.output); if (cmp == 0) { return a.input.get().compareTo(b.input.get()); } else { return cmp; } } }
/** This instance will directly reference ints w/o making a copy. * ints should not be null. */ public IntsRef(int[] ints, int offset, int length) { this.ints = ints; this.offset = offset; this.length = length; assert isValid(); }
@Override public String outputToString(IntsRef output) { return output.toString(); }
final int cmp = bottom.input.get().compareTo(path.input.get()); path.input.setLength(path.input.length() - 1);
/** This instance will directly reference ints w/o making a copy. * ints should not be null. */ public IntsRef(int[] ints, int offset, int length) { this.ints = ints; this.offset = offset; this.length = length; assert isValid(); }
@Override public String outputToString(IntsRef output) { return output.toString(); }
/** Sole constructor. */ public IntsRefBuilder() { ref = new IntsRef(); }
public Set<IntsRef> toFiniteStrings(TokenStream stream) throws IOException { final TokenStreamToAutomaton ts2a = getTokenStreamToAutomaton(); Automaton automaton; try (TokenStream ts = stream) { automaton = toAutomaton(ts, ts2a); } LimitedFiniteStringsIterator finiteStrings = new LimitedFiniteStringsIterator(automaton, maxGraphExpansions); Set<IntsRef> set = new HashSet<>(); for (IntsRef string = finiteStrings.next(); string != null; string = finiteStrings.next()) { set.add(IntsRef.deepCopyOf(string)); } return Collections.unmodifiableSet(set); }
assert lastInput.length() == 0 || input.compareTo(lastInput.get()) >= 0: "inputs are added out of order lastInput=" + lastInput.get() + " vs input=" + input; assert validOutput(output);
@Override public boolean equals(Object other) { if (other == null) { return false; } if (other instanceof IntsRef) { return this.intsEquals((IntsRef) other); } return false; }
/** This instance will directly reference ints w/o making a copy. * ints should not be null. */ public IntsRef(int[] ints, int offset, int length) { this.ints = ints; this.offset = offset; this.length = length; assert isValid(); }
@Override public String outputToString(IntsRef output) { return output.toString(); }
@Override public IntsRef subtract(IntsRef output, IntsRef inc) { assert output != null; assert inc != null; if (inc == NO_OUTPUT) { // no prefix removed return output; } else if (inc.length == output.length) { // entire output removed return NO_OUTPUT; } else { assert inc.length < output.length: "inc.length=" + inc.length + " vs output.length=" + output.length; assert inc.length > 0; return new IntsRef(output.ints, output.offset + inc.length, output.length-inc.length); } }
/** Build a new {@link CharsRef} that has the same content as this builder. */ public IntsRef toIntsRef() { return IntsRef.deepCopyOf(get()); }
public int compare(final IntsRef ints1, final IntsRef ints2) { return ints1.compareTo(ints2); }
@Override public boolean equals(Object other) { if (other == null) { return false; } if (other instanceof IntsRef) { return this.intsEquals((IntsRef) other); } return false; }