@SuppressWarnings("unchecked") public List<Constituent> getConstituentsCoveringToken(int tokenId) { if (tokenId < 0 || tokenId >= this.tokensToConstituents.length) return new ArrayList<>(); if (this.tokensToConstituents[tokenId] == null) return new ArrayList<>(); Queue<Constituent> childrenToConsider = new LinkedList<>(); Set<Constituent> output = new HashSet<>(); output.addAll(this.tokensToConstituents[tokenId]); childrenToConsider.addAll(output); addRelatedNullConstituents(output, childrenToConsider); return new ArrayList<>(output); }
@SuppressWarnings("unchecked") public List<Constituent> getConstituentsCoveringToken(int tokenId) { if (tokenId < 0 || tokenId >= this.tokensToConstituents.length) return new ArrayList<>(); if (this.tokensToConstituents[tokenId] == null) return new ArrayList<>(); Queue<Constituent> childrenToConsider = new LinkedList<>(); Set<Constituent> output = new HashSet<>(); output.addAll(this.tokensToConstituents[tokenId]); childrenToConsider.addAll(output); addRelatedNullConstituents(output, childrenToConsider); return new ArrayList<>(output); }
protected Set<Constituent> getFilteredConstituents(Predicate<Constituent> predicate) { Set<Constituent> output = new HashSet<>(); Queue<Constituent> childrenToConsider = new LinkedList<>(); for (Constituent c : this.constituents) { if (predicate.transform(c)) { output.add(c); childrenToConsider.add(c); } } addRelatedNullConstituents(output, childrenToConsider); return output; }
protected Set<Constituent> getFilteredConstituents(Predicate<Constituent> predicate) { Set<Constituent> output = new HashSet<>(); Queue<Constituent> childrenToConsider = new LinkedList<>(); for (Constituent c : this.constituents) { if (predicate.transform(c)) { output.add(c); childrenToConsider.add(c); } } addRelatedNullConstituents(output, childrenToConsider); return output; }