Skip to content

Commit

Permalink
Update Iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenphuc22 committed Jan 9, 2024
1 parent 1f2ffa2 commit b50d804
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 22 deletions.
41 changes: 19 additions & 22 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions Writerside/topics/Iterator.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,52 @@ Một lợi ích khác của việc sử dụng mẫu thiết kế `Iterator` l

## Cấu Trúc

```mermaid
classDiagram
class Iterator {
<<interface>>
+next() : Element
+hasNext() : boolean
}
class ConcreteIteratorA {
-currentIndex : int
+next() : Element
+hasNext() : boolean
}
class ConcreteIteratorB {
-currentIndex : int
+next() : Element
+hasNext() : boolean
}
class IterableCollection {
<<interface>>
+createIterator() : Iterator
}
class ConcreteCollectionA {
+createIterator() : Iterator
}
class ConcreteCollectionB {
+createIterator() : Iterator
}
class Client {
-iterator : Iterator
}
Iterator <|.. ConcreteIteratorA
Iterator <|.. ConcreteIteratorB
IterableCollection <|.. ConcreteCollectionA
IterableCollection <|.. ConcreteCollectionB
ConcreteCollectionA ..> ConcreteIteratorA : creates
ConcreteCollectionB ..> ConcreteIteratorB : creates
Client --> Iterator : uses
```

- **Iterator** : là một interface hoặc abstract class khai báo các hoạt động cần thiết để duyệt qua các phần tử.
- **Concrete Iterators** : cài đặt các phương thức của Iterator, giữ index khi duyệt qua các phần tử.
- **Iterable Collection** : là một interface tạo ra một hoặc nhiều phương thức cho để lấy `interators` tương thích với `Collection`.
Expand Down

0 comments on commit b50d804

Please sign in to comment.