The iterator pattern provides a way to encapsulate looping through a collection or array of objects.
迭代器模式将提供一种通过对象集合或对象数组封装迭代的方法。
Create an iterator to iterate through the collection.
创建一个迭代器,以便通过集合进行迭代。
The iterator method collect, for example, applies a closure to every element in a collection and returns a new collection with the new values.
例如,迭代器方法collect把闭包应用到集合中的每个元素上,并返回一个带有新值的新集合。
Even as objects get added to the collection, the original Iterator can proceed, working through the items in the original collection.
即使对象加入到了集合中,原来的Iterator也可以进行,继续遍历原来集合中的项。
Using Iterable has some obvious drawbacks when domain modeling, because only one such collection of objects can be so "implicitly" supported via the iterator method.
在域建模的时候,使用Iterable有一些明显的缺陷,因为通过iterator方法只能那么“隐晦”地支持一个那样的对象集合。
When iterating over a Collection, the compiler generates the standard iterator-based idiom.
当在Collection上迭代时,编译器生成标准的基于迭代器的语法。
And Groovy supports an external iterator (also known as a pull iterator because you must request the next item in the collection), shown in Listing 3.
而且Groovy支持外部迭代器(也称为pull迭代器,因为必须请求集合中的下一项),如清单3所示。
Strive for no more than one call after a single cardinality find on a home, or a next on an iterator retrieved from a collection.
在本机上找到一个基数,或者通过迭代器从集合中检索到下一个基数后,尽量使用不超过一个调用。
An iterator is a kind of code helper that lets you quickly access data in any collection or container, one at a time.
迭代器是某种代码助手,可以让您迅速地访问任何集合或容器中的数据,每次一个数据。
Is there a circular dependency between an collection and its iterator?
有一个收集和它的迭代器之间的循环依赖?
Fundamentally, the for loop involves what is known as an iterator, which is used to move through the collection item by item.
本质上,for循环涉及到一个迭代器(iterator),用于在集合中逐项移动。
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
如果集合保证它所含元素的顺序为迭代器的顺序,那么方法必须以相同顺序返回元素。
Some collections will let you get away with removing or adding elements to a collection while iterating across it, but calling remove on the Iterator is a safer practice.
有些集合不允许在迭代时删除或添加元素,但是调用iterator的remove方法是个安全的做法。
If the collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
如果集合保证它所含元素的顺序为迭代器的顺序,那么方法必须以相同顺序返回元素。返回的数组是安全的,集合中不会维持对其的引用。
If the collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
如果集合保证它所含元素的顺序为迭代器的顺序,那么方法必须以相同顺序返回元素。返回的数组是安全的,集合中不会维持对其的引用。
应用推荐