init
This commit is contained in:
commit
c5cd492449
475 changed files with 27928 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
obj: concept
|
||||
---
|
||||
|
||||
# Iterator Pattern
|
||||
|
||||
## **Description:**
|
||||
The Iterator Pattern is a behavioral design pattern that provides a way to access the elements of a collection sequentially without exposing its underlying representation. It defines a common interface for iterating over various types of collections, such as arrays, lists, trees, and more. The pattern separates the responsibility of iteration from the collection itself, promoting encapsulation and flexibility.
|
||||
|
||||
## **Example:**
|
||||
[Rust](../../languages/Rust.md) has iterators which can be extended by functional programming methods like `map()`, etc.
|
||||
```rust
|
||||
trait Iterator<T> {
|
||||
fn has_next(&self) -> bool;
|
||||
fn next(&mut self) -> Option<T>;
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue