Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プロジェクトに次のコード行があります。
Iterator<Node> i = graph.nodes();
graph.nodes() は、prefuse で定義されているメソッドです。
イテレータに型チェックを追加したいのですが、どうすればいいですか?
Guavaを使用する場合は、次のことができます
Iterator<Node> iterator = Iterators.filter(theOriginalIterator, Node.class);
返された反復子は、指定された型に対応する要素のみを継続することが保証されています。Iterable(ところで同様の方法も利用可能です)
Iterable
見る
Iterators.filter(iterator, class)
Iterables.filter(iterable, class)