iterator

package
v0.0.0-...-e059a18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis struct{}

func (*Analysis) Visit

func (a *Analysis) Visit()

type Container

type Container struct {
	// contains filtered or unexported fields
}

创建容器

func (*Container) Add

func (c *Container) Add(visitor Visitor)

func (*Container) Remove

func (c *Container) Remove(index int)

type Iterator

type Iterator struct {
	Container
	// contains filtered or unexported fields
}
设计思想:
	1. Iterator结构体
		实现Next()  HasNext()方法
	2. Container容器
		容器实现添加 移除Visitor 和

创建迭代器

func NewIterator

func NewIterator() *Iterator

工厂方法创建迭代器

func (*Iterator) HasNext

func (i *Iterator) HasNext() bool

func (*Iterator) Next

func (i *Iterator) Next() Visitor

type Teacher

type Teacher struct{}

创建具体的visitor对象

func (*Teacher) Visit

func (t *Teacher) Visit()

type Visitor

type Visitor interface {
	Visit()
}

创建Visitor接口

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL