深入浅出的设计的模式之迭代器的模式精析.pptVIP

  • 5
  • 0
  • 约小于1千字
  • 约 68页
  • 2020-12-28 发布于福建
  • 举报

深入浅出的设计的模式之迭代器的模式精析.ppt

迭代器模式 本章内容 ·迭代器的引入 迭代器模式 迭代器模式的举例 迭代器模式的理解 ·迭代器模式的应用 迭代器模式的引入 ·对于容器性数据结构,有时需要访问其 中的每一个元素。由于每一个种数据结 构的存储不同,访问每一个元素有差别 链表 二叉树 向量 链表的遍历 Object temp= head while( temp != null) read temp. value0; temp〓 temp nextO; 向量的遍历 · int current〓0 while(current vector sizeor return vector. get(current) current十 二叉树的遍历(先序) if( root !=null) stack. push(root) while(stack, isEmpty or Binary Tree old stack popo Object result s old value0 ·if( old right0 IsEmpty0)压入右孩子 ·i( old. lefty0 ISEmpty()压入左孩子 ·例如常见的电视,可以定义一个遥控器 的,每个工厂生产的电视机都有配套的 遥控器,电视的频道为tem,每个遥控 器都会有遍历的功能,用以遍历所有的 频道

文档评论(0)

1亿VIP精品文档

相关文档