インタフェースIterable<T>
- 型パラメータ:
T- イテレータによって返される要素のタイプ
- 既知のすべてのサブインタフェース:
BeanContext, BeanContextServices, BlockingDeque<E>, BlockingQueue<E>, ClassModel, ClassReader, CodeAttribute, CodeModel, Collection<E>, CompoundElement<E>, ConstantPool, ConstantPoolBuilder, Deque<E>, DirectoryStream<T>, EventSet, FieldModel, List<E>, MethodModel, NavigableSet<E>, NodeSetData<T>, Path, Queue<E>, SecureDirectoryStream<T>, SequencedCollection<E>, SequencedSet<E>, Set<E>, SortedSet<E>, TransferQueue<E>, XPathNodes
- 既知のすべての実装クラス:
AbstractCollection, AbstractList, AbstractQueue, AbstractSequentialList, AbstractSet, ArrayBlockingQueue, ArrayDeque, ArrayList, AttributeList, BatchUpdateException, BeanContextServicesSupport, BeanContextSupport, ConcurrentHashMap.KeySetView, ConcurrentLinkedDeque, ConcurrentLinkedQueue, ConcurrentSkipListSet, CopyOnWriteArrayList, CopyOnWriteArraySet, DataTruncation, DelayQueue, DocTreePath, EnumSet, HashSet, JobStateReasons, LinkedBlockingDeque, LinkedBlockingQueue, LinkedHashSet, LinkedList, LinkedTransferQueue, PriorityBlockingQueue, PriorityQueue, RoleList, RoleUnresolvedList, RowSetWarning, SerialException, ServiceLoader, SQLClientInfoException, SQLDataException, SQLException, SQLFeatureNotSupportedException, SQLIntegrityConstraintViolationException, SQLInvalidAuthorizationSpecException, SQLNonTransientConnectionException, SQLNonTransientException, SQLRecoverableException, SQLSyntaxErrorException, SQLTimeoutException, SQLTransactionRollbackException, SQLTransientConnectionException, SQLTransientException, SQLWarning, Stack, SyncFactoryException, SynchronousQueue, SyncProviderException, TreePath, TreeSet, Vector
public interface Iterable<T>
このインタフェースを実装すると、オブジェクトが拡張
for文("for-eachループ"文とも呼ばれる)のターゲットになることができます。- Java言語仕様を参照してください:
-
14.14.2 拡張された
for文 - 導入されたバージョン:
- 1.5
-
メソッドのサマリー
修飾子と型メソッド説明default voidIterableの各要素に対して指定されたアクションを、すべての要素が処理されるか、アクションが例外をスローするまで実行します。iterator()型Tの要素のイテレータを返します。default Spliterator<T> このIterableによって記述される要素に対するSpliteratorを作成します。
-
メソッドの詳細
-
iterator
-
forEach
Iterableの各要素に対して指定されたアクションを、すべての要素が処理されるか、アクションが例外をスローするまで実行します。 反復の順序でアクションが実行されます(その順序が指定されている場合)。 アクションによってスローされた例外は、呼出し側に中継されます。このメソッドの動作は、オーバーライドするクラスが同時変更ポリシーを指定していないかぎり、要素の基礎となるソースを変更する副作用をアクションが実行する場合には指定されません。
- 実装要件:
デフォルト実装の動作は次のようになります。
for (T t : this) action.accept(t);- パラメータ:
action- 各要素に対して実行されるアクション- スロー:
NullPointerException- 指定されたアクションがnullである場合- 導入されたバージョン:
- 1.8
-
spliterator
default Spliterator<T> spliterator()このIterableによって記述される要素に対するSpliteratorを作成します。- 実装要件:
- デフォルト実装では、反復可能オブジェクトの
Iteratorから早期バインディングのスプリッテレータを作成します。 そのスプリッテレータは、その反復可能オブジェクトのイテレータのフェイルファスト特性を継承します。 - 実装上のノート:
- デフォルト実装は通常、オーバーライドする必要があります。 デフォルト実装から返されるスプリッテレータは分割機能が貧弱であり、それぞれに合ったサイズがないため、スプリッテレータの特性がまったく生かされません。 クラスを実装することで、より良い実装を提供できることがほとんどです。
- 戻り値:
- この
Iterableによって記述される要素に対するSpliterator - 導入されたバージョン:
- 1.8
-