由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个stl的iterator问题
相关主题
请问怎样写没有parent pointer的BST iterator?topcoder- strange country problem.
reverse an arrayL家的高频题merge k sorted arrays giving iterators求讨论!
请教 Iterator 一题Interview Question
谁对design pattern比较熟?"简单的"linklist的问题
How can one determine whether a singly linked list has a cycle?array contains two integer that sum up to 7
问个最近面试里的题目各位刷友,leetcode里的题目:Copy List with Random Pointer
我发现我竟然学会了12种tree traversal的办法有人同看Populating Next Right Pointers in Each Node II的recursive写法么?
一道onsite面试题看到一个题目
相关话题的讨论汇总
话题: iterators话题: pointers话题: iterator话题: vi话题: int
进入JobHunting版参与讨论
1 (共1页)
m*****g
发帖数: 226
1
stl container use iterators instead of pointers.
however, what if i want to use a pointer to pointers, can i do it with
iterators? how?
for example, with normal pointers, i can do
int *A, *B;
int **P;
if(...) *P = A;
else *P=B;
how to do this with iterators?
thx
h**6
发帖数: 4160
2
I think you can use a pointer to an iterator as below:
typdef vector vi;
void main()
{
int input[] = {1, 4, 5};
vi weight = vi(input, input+sizeof(input)/sizeof(input[0]));
vi::iterator it1 = weight.begin();
vi::iterator it2 = weight.end()-1;
vi::iterator *pit = new vi::iterator;
if(1+1 == 3)
*pit = it1;
else
*pit = it2;
int result = **pit;
delete pit;
cout< }
m*****g
发帖数: 226
3
多谢!
1 (共1页)
进入JobHunting版参与讨论
相关主题
看到一个题目How can one determine whether a singly linked list has a cycle?
Bloomberg 电面问个最近面试里的题目
hash_map 的遍历问题我发现我竟然学会了12种tree traversal的办法
how to query in the universal hash table?一道onsite面试题
请问怎样写没有parent pointer的BST iterator?topcoder- strange country problem.
reverse an arrayL家的高频题merge k sorted arrays giving iterators求讨论!
请教 Iterator 一题Interview Question
谁对design pattern比较熟?"简单的"linklist的问题
相关话题的讨论汇总
话题: iterators话题: pointers话题: iterator话题: vi话题: int