自己编写一个find查找函数:
static bool find(vector bn_vec, int an){
for(vector::iterator bn_vec_it = bn_vec.begin(); bn_vec_it != bn_vec.end(); bn_vec_it++){
if( *bn_vec_it == an )
return true;
}
return...
分类:
编程语言 时间:
2014-09-12 17:10:23
阅读次数:
1143
先看看官方手册的说明吧:
pairs (t)If t has a metamethod __pairs, calls it with t as argument and returns the first three results from the call.
Otherwise, returns three values: the next function, the table t, a...
分类:
其他好文 时间:
2014-09-12 01:16:42
阅读次数:
304
Problem 1:vector coll = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };vector::const_iterator pos = find (coll.cbegin(), coll.cend(),5);cout ::const_reverse_iterator r...
分类:
其他好文 时间:
2014-09-11 18:56:12
阅读次数:
226
先有一个示例: import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
im...
分类:
其他好文 时间:
2014-09-11 15:03:12
阅读次数:
163
安卓开发或者Java开发中经常使用Iterator遍历,尝试总结一下for配合get()的遍历和Iterator配合next()遍历的区别,进入Java的JDK源码中进行深度剖析一下...
分类:
其他好文 时间:
2014-09-11 13:58:12
阅读次数:
179
前言 在java中提供给我们了一些类似C++泛型的简单集合,list,set,map等。这里,简单介绍一下这些集合容器的使用方法,以及复杂对象元素的自定义排序。 首先看一下集合的框架图: 由于collection也继承了Iterator和comparable接口,因此我们可以使用Iterato...
分类:
编程语言 时间:
2014-09-10 20:56:11
阅读次数:
313
在项目开发中,常常会用到Map,而map的存放是无序的,它存放的是键值对,也就是一个键对应一个值。有时需要将Map的key和value转化为List来进行相关的操作,现在通过实例来实现Map的key和value的转化。...
分类:
其他好文 时间:
2014-09-10 10:51:50
阅读次数:
461
一、引言 在上篇博文中分享了我对命令模式的理解,命令模式主要是把行为进行抽象成命令,使得请求者的行为和接受者的行为形成低耦合。在一章中,将介绍一下迭代器模式。下面废话不多说了,直接进入本博文的主题。二、迭代器模式的介绍 迭代器是针对集合对象而生的,对于集合对象而言,必然涉及到集合元素的添加删除操.....
分类:
其他好文 时间:
2014-09-10 00:24:59
阅读次数:
309
struts2的s:iterator 可以遍历 数据栈里面的任何数组,集合等等 以下几个简单的demo: s:iterator 标签有3个属性: value:被迭代的集合 id :指定集合里面的元素的id ...
分类:
其他好文 时间:
2014-09-09 10:28:38
阅读次数:
375
1.the concept of List2. how to define a method of myself3.how to iterator a listPS:for Step 2,3. it is related with a key word: 'def'. we define a fun...
分类:
编程语言 时间:
2014-09-07 21:00:15
阅读次数:
229