博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
251.Flatten 2D Vector
阅读量:4653 次
发布时间:2019-06-09

本文共 1287 字,大约阅读时间需要 4 分钟。

/* * 251.Flatten 2D Vector * 2016-6-20 by Mingyang *------- boolean hasNext() * Returns true if the iteration has more elements.  * (In other words, returns true if next() would return an element rather than throwing an exception.) *-------E next() *Returns the next element in the iteration. *Returns: *the next element in the iteration *Throws: *NoSuchElementException - if the iteration has no more elements *关键问题是掌握好Iterator的用法 */class Vector2D {      private Iterator
> row = null; private Iterator
col = null; public Vector2D(List
> vec2d) { row = vec2d.iterator(); if(row.hasNext()) col = row.next().iterator(); } public int next() { int lastValue = col.next(); return lastValue; } public boolean hasNext() { if(col == null) { return false; } if(col.hasNext()) { return true; } else { while(row.hasNext()) { col = row.next().iterator(); if(col.hasNext()) return true; } return false; } }

 

转载于:https://www.cnblogs.com/zmyvszk/p/5602557.html

你可能感兴趣的文章
sql语句的各种模糊查询语句
查看>>
C#操作OFFICE一(EXCEL)
查看>>
【js操作url参数】获取指定url参数值、取指定url参数并转为json对象
查看>>
移动端单屏解决方案
查看>>
web渗透测试基本步骤
查看>>
使用Struts2标签遍历集合
查看>>
angular.isUndefined()
查看>>
第一次软件工程作业(改进版)
查看>>
网络流24题-飞行员配对方案问题
查看>>
Jenkins 2.16.3默认没有Launch agent via Java Web Start,如何配置使用
查看>>
引入css的四种方式
查看>>
iOS开发UI篇—transframe属性(形变)
查看>>
3月7日 ArrayList集合
查看>>
jsp 环境配置记录
查看>>
Python03
查看>>
LOJ 2537 「PKUWC2018」Minimax
查看>>
使用java中replaceAll方法替换字符串中的反斜杠
查看>>
Some configure
查看>>
流量调整和限流技术 【转载】
查看>>
1 线性空间
查看>>