由买买提看人间百态

topics

全部话题 - 话题: iter
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
a*********r
发帖数: 7
1
来自主题: Programming版 - c++ iterator 弱问
thanks, that is a typo, but i still can't assign elements.begin() to
iter in void A::begin(), do u know how to fix that?
m******s
发帖数: 612
2
来自主题: Programming版 - c++ iterator 弱问
map is not a mutable iterator, so mutable can't work here.
j*****k
发帖数: 1198
3
来自主题: Programming版 - iterator一问
template
void lstack::print(ostream& os)
{
if(data==NULL) return;
vector::iterator i; // error: expected `;' before ‘i’
for(i=data->begin(); iend();i++) //error: ‘i’ was not
declared in this scope
os< os< return;
};
大家帮忙看看,这两个错误怎么回事?不解。用的是gcc version 4.1.3 20070929
t****t
发帖数: 6806
4
来自主题: Programming版 - iterator一问
typename vector::iterator i;
h****e
发帖数: 2125
5
来自主题: Programming版 - iterator一问
iterator is a dependent name in 'vector', you have to explicitly bring it
into the vector's scope or fully qualify it.
w***g
发帖数: 5958
6
来自主题: Programming版 - C++如何快速输入iterator类型名
比如定义一个变量 vector > map_vector;
然后要用
for (... it = map_vector.begin(); it != map_vector.end() ++it) {
}
"..."的地方难道只能输入vector >::const_iterator? 每次用到都
输这么一长串也太变态了吧?专门为这个iterator type定义一个类型又太ad hoc。不知
道有没有什么好的办法。
c**a
发帖数: 316
7
可以用 swap 来交换 pointer 和 iterator 吗?
l********s
发帖数: 358
8
来自主题: Programming版 - Pointer to iterator?
string::iterator it = s.begin() + 3; //not pretty....
Why it is not pretty???
P********e
发帖数: 2610
9
来自主题: Programming版 - vector::iterator不对
首先要有vector,然后才有他的iterator
c**m
发帖数: 30
10
来自主题: Programming版 - vector::iterator不对
because you are defining a template so vector can't be defined until you
instantiate the template, but before vector can be defined the template
has to be defined first. chicken and egg problem. Anyway, the effect is
when the compiler is trying define the template it has no way of figuring
out what vector::iterator is. If you think about it you would see why.
The solution is, of course, you explicitly tell the compiler what it is: a
typename. like below:
template
void f
h****8
发帖数: 599
11
就access而言应该没有区别 但是泛性算法都是iterator实现的吧
S**I
发帖数: 15689
12
STL对random access iterator的实现有专门的优化
s*****g
发帖数: 5159
13
来自主题: Programming版 - [请教]iterator and reference in C++ vector
The operator [] of a vector returns the reference to an element of the vecto
r
member function .end() returns an iterator of the last element of the vector
.
I want to judge if a particular element is the last element of the vector, b
ut I cannot do the following
z****e
发帖数: 2024
14
btw,you need to 打回去重学。
if you want explicit instantiation, you should do:
f::iterator>(vi.begin(), vi.end());

is
z****e
发帖数: 2024
15
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
iterator is a smart pointer.
all thing related is about smart pointer vs naked pointer.
such like:
1.resource management
2.exception safety
3.reference counter
etc,
smart pointer has cp-ctor and op= overloaded.
but using smart pointer, usually you lose the usual pointer arithmetic.
to calculate smart pointer difference, you need to call distance(first, last).
nothing comes at no cost, smart pointer is usually more space consuming and time consuming than regular pointer. But being a coder, you ge
g***8
发帖数: 27
16
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
iterator is a constructed object which behave like a pointer
S**I
发帖数: 15689
17
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
我的理解是:iterator是一种design pattern,pointer不是。

界面
啊。
l******e
发帖数: 12192
18
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
tell him:
iterators are evil!
-Andrei Alexandrescu
haha
k*******d
发帖数: 1340
19
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
我印象中iterator对resource allocation没怎么支持吧,它支持RAII?貌似不是,所以
,把他和tr1::shared_ptr等同是不够准确的,当然,如果说广义的smart pointer那的
确有联系
c**********e
发帖数: 2007
20
来自主题: Programming版 - C++ Q11: iterator
Which one of the following standard containers does NOT invalidate iterators
when elements are inserted within the existing sequence?
a) queue
b) deque
c) list
d) stack
e) valarray
E*U
发帖数: 2028
21
来自主题: Programming版 - C++ Q11: iterator
c

iterators
p*u
发帖数: 2454
22
来自主题: Programming版 - stl iterator has "NULL" like const?

"NULL"
no. if u use it without setting a valid value it would be undefined
behavior. if u need an initial state u can use pointer to iterator, which
is more convoluted though.
g*********s
发帖数: 1782
23
来自主题: Programming版 - stl iterator has "NULL" like const?
So it seems I have to take the following weird detour?
std::list dummy_queue;
std::list::iterator dummy_it (dummy_queue.end());
X.resize(x_sz, dummy_it);
What if dummy_queue is changed later? That means the value in X is stale and potentially dangerous?
Any better solution? We don't have such headache if we just use self-defined doubly linked list and the initial value NULL for X elements. I expect a stl based solution can achieve similar behaviour.
w****i
发帖数: 964
24
Suppose the array is a1...a9
to iterate it in this order: a1, a9, a2, a8, a3, a7, a4, a6, a5
how to write it in a simple form, say a for loop?
d****i
发帖数: 4809
25
来自主题: Programming版 - 弱问c++ iterator 和 pointer区别
list 当然能用指针来access, iterator 就是为了
方便你使用,底层就是用指针来实现
Y**G
发帖数: 1089
26
来自主题: Programming版 - 有没有把多个Iterable merge成一个的
找到一个google collection中的工具不错: Iterables.concat
h*******d
发帖数: 272
27
大家好 生手急求
我用SPSS 的IMPUTATION 功能填补我原始数据中的MISSING VALUE (SAS 也有这个功能
,但PROJECT 马上要交 没功夫折腾SAS 就偷懒用SPSS)
我学了半天还没明白 比如 SPSS中 iteration=5,那就会出来5组新数据 就是原始数据
+系统填补上的数据 (重复5次 每次不一样的填补数据)
然后我分析怎么办呢? 到底拿哪组数据呢 我试着5组都分析 发现结果还是有不同的
和原始数据的结果差的更大。 到底怎么把这5组数据 最后总结为我最终的模型呢?
肯请大家指点
t******g
发帖数: 372
28
it is constrOptim
100 is default
if you dont know what iteration does, then ask yourself how optimization
works
if you cant answer that, it is not wise to use something you dont understand.
c***u
发帖数: 4107
29
来自主题: DataSciences版 - pig能做iterative的问题吗?
最近在自学, 请问, pig能做iterative的问题吗, 比如一些matrix update的问题的.
比如nonnegative matrix factorization, 有一个nonnegative matrix N, 要分解成2
个matrix A和B, 使得|N-A*B|尽可能的小
标准算法是: 先随机生成2个矩阵A和B. 然后先固定A, 按照一个规则用A和N去更新B;
再固定B, 用B和N去更新A; 一直如此循环更新, 直到|N-A*B|足够小
不知道用pig或者hive, 能解决如此问题吗?
(不是research问题, 5/6年就有人用mapreduce+java发了N片文章)
当然, 我是说不另外写UDFs的情形下
D**u
发帖数: 288
30
来自主题: DataSciences版 - pig能做iterative的问题吗?
NMF 最近很火,image processing, text mining 都用上了。NMF可以用来跟PCA比较,
多了一个non-negative的限制, 结果有了很多很好的性质。caoyu的想法很intuitive,
因为NMF跟PCA解法上的一个很大的不同就是,NMF 可以靠iterative的update去解决,
而PCA是一次性的对covariance matrix做decomposition.
x******a
发帖数: 6336
31
//main()
#include
#include
#include "linkedlist.h"
int main()
{
LinkedList myList(5, "luke");
Iterator myIterator=myList.begin();
myList.insert(myIterator, "leia");
myIterator.forward();
myList.erase(myIterator);
myList.insert(myIterator, "chewbca"); 《======出问题。
myList[2]="han";
for (int i=0; i std::cout< }
myList.insert(myIterator, "chewbca"); 《======出问题。
这一句运行起来ta... 阅读全帖
g****g
发帖数: 1828
32
来自主题: WaterWorld版 - vector
SGI Logo
vector

Category: containers Component type: type
Description
A vector is a Sequence that supports random access to elements, constant
time insertion and removal of elements at the end, and linear time insertion
and removal of elements at the beginning or in the middle. The number of
elements in a vector may vary dynamically; memory management is automatic.
Vector is the simplest of the STL container classes, and in many cases the
most efficient.
Example
vector V;
... 阅读全帖
M****z
发帖数: 1058
33
来自主题: Programming版 - agile 说白了就是让外行中间人滚蛋
其实各方面都会存在这样的人,不过非技术人员概率更大,因为他们不是工具的直接使
用者。
这篇文章我觉得靠谱,希望有帮助:
Why Agile Is So Hard
http://www.uxmatters.com/mt/archives/2013/08/why-agile-is-so-ha
Is agile a dirty word in your company or among the members of your UX team?
Do you hear the term lean UX and groan? It’s okay—and not really
surprising—if your answer is yes. Agile is hard, and we all know it. But
since agile is likely to stick around for a while, I’m sure you’ve thought
about how to make it easier.
However, the question shouldn’t be h... 阅读全帖
w*********g
发帖数: 30882
34
这两年,兔子的国家重器和高端武器层出不穷。
俺的巴掌红得都要拍不动。
裤衩已成灰。
当然还有好多小兔子半信半疑。
过年时太忙,都没空,现在总算好点。
俺现在心情不错,就给大家818,为什么兔子这些年,这么牛逼,发展速度这么快。
当然,俺说的是军工和科研系统方面。
长期更新啊。大家慢慢看。
亲身经历,绝对原创。
为什么,兔子家的进步神速?
兔子家,是真正把霉菌在IT最高端的仿真模拟,和毛熊强大的系统分析设计以及体
系对抗思想,给结合起来了。
兔子家,正是靠了计算机仿真和模拟,所以节省了大量的实物实验,节省了成本,
提高了速度。
这,就是后发的巨大优势。这个优势,是上世纪90年代后期,尤其是2000年之后,
PC以及各种高端工具软件普及之后(UG,CATIA,ANSYS,Fluent……),才具有的优势。
有人问,为什么美帝善于仿真模拟,毛熊善于系统分析设计,体系对抗到底是啥玩
意?
这个,算是问道点子上了。
这个话题很大,俺只能简单滴回答,另外讲讲俺的亲身经历。
这个要从二战说起,霉菌,继承的是德国的思想,高大上的武器,高素质军人,高
超地战术思想和能力,类似狼或者鹰。
毛熊,则是完全不... 阅读全帖
r******r
发帖数: 700
35
来自主题: JobHunting版 - Apple Siri 组 Java 测试题
/**
* Using {@link AppleExercise.Problem1.SampleCache} as a starting point,
answer questions 1-3 by
* creating 3 new inner classes within {@link AppleExercise.Problem1}
below.
*/
public static class Problem1 {
public interface Cache {
public void put(Object key, Object value);
public Object get(Object key);
}
public static class SampleCache implements Cache {
private Map map;
public SampleCache() {
... 阅读全帖
d*******g
发帖数: 122
36
来自主题: Programming版 - 基本功不扎实,问个问题
前面的bool和后面的const我都省掉了,因为这些与他问的问题无关,这种刺儿就不用
挑了吧。否则你写的iterator和iterator又是什么意思?iterator是一个模板?
我刚看了一下gcc4.7.1的list类的iterator,与同类型比较的operator ==()为成员函
数,
iterator::operator==(const iterator&)
const_iterator::operator==(const const_iterator&)
但是iterator与const_iterator之间的比较为非成员函数
operator==(const iterator&, const const_iterator&)
这是因为定义iterator在先,所以无法在iterator的花括号内定义 iterator::
operator==(const const_iterator&)。那么与其先声明一个成员函数,然后在定义了
const_iterator之后再给出这个函数的定义,那不如直接定义非成员函数好了。
set和map的iterator情况与l... 阅读全帖
s*****V
发帖数: 21731
37
从法国卡达哈什(Cadarache)ITER总部获悉, 6月3日,由我所研制的国际热核聚变实
验堆计划(ITER)极向场导体采购包第二阶段(PhaseⅡ)极向场PF5导体成功完成交付
。这是中方首件交付ITER现场的产品,也是ITER七方中首件交付ITER现场的大件产品。
PF导体采购包是我所继环向场后承担的第二个ITER导体采购包。中方承担了ITER
PF导体采购包PF2/3/4和PF5导体,总共包括64根导体,均有由我所负责制造。ITER PF
导体是外方内圆的异型导体,其制造工艺复杂,包括焊接工艺、无损检测技术、导体成
型及收绕技术等。我所超导磁体及电力节能应用技术研究室通过自身努力,完成了异型
管焊接、铠甲及焊缝无损检测、导体成型及收绕型技术的研发。2012年1月12日,F5导
体在ITER国际组织(IO)及中国国际核聚变能源计划执行中心(CNDA)的见证下顺利在我
所完成。
导体完成后,科研人员对其进行了各种接收测试,同时进行了导体交付所需文件的
准备。2013年3月在所有交付文件通过的基础上,按照PF导体技术要求,我所将PF5导体
进行了分割与包装。4月25日,CNDA见证... 阅读全帖
s*****V
发帖数: 21731
38
从法国卡达哈什(Cadarache)ITER总部获悉, 6月3日,由我所研制的国际热核聚变实
验堆计划(ITER)极向场导体采购包第二阶段(PhaseⅡ)极向场PF5导体成功完成交付
。这是中方首件交付ITER现场的产品,也是ITER七方中首件交付ITER现场的大件产品。
PF导体采购包是我所继环向场后承担的第二个ITER导体采购包。中方承担了ITER
PF导体采购包PF2/3/4和PF5导体,总共包括64根导体,均有由我所负责制造。ITER PF
导体是外方内圆的异型导体,其制造工艺复杂,包括焊接工艺、无损检测技术、导体成
型及收绕技术等。我所超导磁体及电力节能应用技术研究室通过自身努力,完成了异型
管焊接、铠甲及焊缝无损检测、导体成型及收绕型技术的研发。2012年1月12日,F5导
体在ITER国际组织(IO)及中国国际核聚变能源计划执行中心(CNDA)的见证下顺利在我
所完成。
导体完成后,科研人员对其进行了各种接收测试,同时进行了导体交付所需文件的
准备。2013年3月在所有交付文件通过的基础上,按照PF导体技术要求,我所将PF5导体
进行了分割与包装。4月25日,CNDA见证... 阅读全帖
b*****c
发帖数: 1103
39
来自主题: JobHunting版 - 上个题大家给评评 (G家的)
list (list span_lis, Node & span)
{
if (span_lis==NULL) return NULL;
list::iterator iter=span_lis.begin();
while (iter!=span_lis.end())
{
if ((*iter).second>=span.first-1)
{
(*iter).first=min((*iter).first,span.first);
(*iter).second=max((*iter).second,span.second);
while (++iter !=span_lis.end())
{
if ((*iter).first>*boost::prior(iter).second+1)
{
break;
}
else
if ((*iter).second>*boost::prio... 阅读全帖
b*****c
发帖数: 1103
40
来自主题: JobHunting版 - 上个题大家给评评 (G家的)
list (list span_lis, Node & span)
{
if (span_lis==NULL) return NULL;
list::iterator iter=span_lis.begin();
while (iter!=span_lis.end())
{
if ((*iter).second>=span.first-1)
{
(*iter).first=min((*iter).first,span.first);
(*iter).second=max((*iter).second,span.second);
while (++iter !=span_lis.end())
{
if ((*iter).first>*boost::prior(iter).second+1)
{
break;
}
else
if ((*iter).second>*boost::prio... 阅读全帖
s***e
发帖数: 403
41
来自主题: JobHunting版 - 我今年的第一次面试,恶心坏了
没有什么太大的难度啊
设置两个变量,back_left, back_right,然后先向左移动。在向parent移动的时候识
别是从左边子树移动来的还是从右边子树移动来的。如果是从右边子树移动来的说明所
有右边子树已经访问过,所以就向上移动,否则访问右边子树。最后从右边移动到root
的时候表明访问完毕。需要考察的也就是根节点的右子树是否访问完全。
下面是代码,可能有bug,不过思路大致如此。
struct TreeNode
{
TreeNode* parent;
TreeNode* left;
TreeNode* right;
int value;
explicit TreeNode(int val, TreeNode* p=nullptr) :
parent(p), left(nullptr), right(nullptr), value(val)
{}
};
void traverse(TreeNode* node)
{
TreeNode* iter=node;
bool backleft=false... 阅读全帖
s*******n
发帖数: 343
42
近期发生的日本核泄漏事件持续牵动着世界各国的神经,和平开发利用核能再次成为瞩
目的焦点。
就在上个月,国内核聚变界的100余名专家代表也聚集到了一起,由科技部主办的核聚
变能发展研究人才工作会议在中国科技大学举行。与会专家纷纷表示,抓紧培养和储备
核聚变人才后备力量,已经到了刻不容缓的地步。
国内多项核聚变技术装置已迈入国际先进水平
目前世界上的核电站利用核裂变来发电,核裂变在产生巨大能量的同时也产生强大的辐
射,废料很难处理。此外,作核材料的铀、钍蕴藏量非常有限。
与核裂变能相比,核聚变能是无污染、无长寿命放射性核废料、资源无限的理想能源,
例如,每升海水中所含的氘通过核聚变反应可以产生相当于300公升汽油燃烧所放出的
能量,而海水取之不尽,用之不竭。
但是目前人类已经能够控制和利用核裂变能,而控制和利用核聚变能则需要历经长期艰
苦的研发过程。
一位不愿意透露姓名的专家向中国青年报记者介绍,目前人类利用托克马克装置开发核
聚变能的科学可行性已经得到证实:“等离子体最高温度可达2亿~4亿度;最高聚变输
出功率超过16兆瓦,聚变输出功率/输入功率比值已经达到1.25。”也就是说,建造核
... 阅读全帖
w*********g
发帖数: 30882
43
来自主题: Military版 - 中国已站在核聚变研究前沿
中国已站在核聚变研究前沿
发贴人:60.180.126.*发贴时间:2011-11-2【复制本帖地址】[必看]
壹互联2011 2012 香港VPS核聚变 (2011-06-17)
天河一号超级计算机将服务核聚变能源开发领域 (2011-05-29)
“天河一号”计算机首次服务核聚变能源开发领域 (2011-05-21)
中国的孩子不如美国的虫子。(图) (2011-11-03)
中国和周边国家勘界后:真实的陆地面积大曝光 (2011-11-03)
世界震惊:中国空间站升空透露八大惊天机密 (2011-11-03)
对网站优化收录量造成影响的来源 (2011-11-03)
美欧看傻:中国空间站升空透露的八大惊天机密 (2011-11-03)
地瓜地瓜,我是土豆,前沿阵地吃紧,向我开炮 (2011-10-21)
独创自我风格,占领时尚前沿,新帕萨特展现人们戏中所想(图) (2011-10-17)
天宫一号 瞄准29日21时16分至21时31分窗口前沿发射(图) (2011-09-28)
伊朗宣布将倾全国之力加快核聚变研究进程 (2010-07-27)
我国与世界联... 阅读全帖
Z**********4
发帖数: 528
44
来自主题: JobHunting版 - 问一下careercup一道题
我的意思是不用整个pair用一个hash map就可以了。不过我想做点改动 利用hash里面
key对应的value来标志对(3,4)已经找过了,下次不论是(4,3)还是(3,4)都视
而不见。
hash_map hash;
vector::iterator iter;
vector result;
for(iter = array.begin(); iter!= array.end(); iter++){
if(hash.find(*iter) == hash.end() && hash.find(n-*iter) == hash.end(
)){
hash[n-*iter] = 1; //这是第一次遇见3的时候,存入 4->1
}
else if(hash[*iter]==1){ //发现hash里面有4,而且value是1 就算找到了
(3,4)
hash[*iter]=0; //将hash... 阅读全帖
s***e
发帖数: 403
45
/**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* };
*/
class Solution {
public:
RandomListNode *copyRandomList(RandomListNode *head) {
map corresponding;
corresponding[nullptr] = nullptr;

RandomListNode* nhead = new RandomListNode(0);
RandomListNode* last = ... 阅读全帖
d**********o
发帖数: 279
46
没想出怎么用stack, 大牛讲解一下?
"""
Write a iterator to iterate a nested array.
For example, for given array: [1, 2, [3, [4, 5], [6, 7], 8], 9, 10]
call iterator.next() 10 times should return 1,2,3,4,5,6,7,8,9,10.
"""
def traverse(l):
if not l:
return
for i in l:
if isinstance(i, list):
traverse(i)
else:
print i
class NestIterator(object):
def __init__(self, l):
self.l = l
self.cur = -1
self.iterator = None

def next(self):
if self.iterator and s... 阅读全帖
m********7
发帖数: 1368
47
来自主题: JobHunting版 - 面试题
和我这个很相似。。大牛写了多久?
List * inPlaceInsertionSort(List *head){
if(!head) throw(“empty list”);
// assume head is sorted, and unsort is unsorted
List *unsort = head->next;
while(unsort){
// take the front element from unsort
List *prev = NULL;
List *iter = head;
List *key = unsort;
// iterate within sorted list
while(iter){
if(iter->data < key->data){
prev = iter;
iter = iter->next;
}
... 阅读全帖
M*V
发帖数: 3205
48
来自主题: ChinaNews版 - PPT 来了
India plays key role in building super machine that will offer unlimited
energy
LONDON: India is developing the heaviest and the largest parts of the
Tokamak, the machine behind the biggest scientific collaboration on the
planet, to produce unlimited supplies of cheap, clean, safe and commercial
energy from atomic fusion.
The international nuclear fusion project known as ITER, meaning "the way" in
Latin, is based on the 'tokamak' concept of magnetic confinement, in which
the plasma is contained ... 阅读全帖
y**********a
发帖数: 824
49
来自主题: Military版 - PPT 来了
India plays key role in building super machine that will offer unlimited
energy
LONDON: India is developing the heaviest and the largest parts of the
Tokamak, the machine behind the biggest scientific collaboration on the
planet, to produce unlimited supplies of cheap, clean, safe and commercial
energy from atomic fusion.
The international nuclear fusion project known as ITER, meaning "the way" in
Latin, is based on the 'tokamak' concept of magnetic confinement, in which
the plasma is contained ... 阅读全帖
f**d
发帖数: 768
50
来自主题: Neuroscience版 - eBook: From computer to brain
这是一本计算神经科学的优秀著作,全文拷贝这里(图和公式缺),有兴趣的同学可以
阅读
如需要,我可以分享PDF文件(--仅供个人学习,无商业用途)
From Computer to Brain
William W. Lytton
From Computer to Brain
Foundations of Computational Neuroscience
Springer
William W. Lytton, M.D.
Associate Professor, State University of New York, Downstato, Brooklyn, NY
Visiting Associate Professor, University of Wisconsin, Madison
Visiting Associate Professor, Polytechnic University, Brooklyn, NY
Staff Neurologist., Kings County Hospital, Brooklyn, NY
In From Computer to Brain: ... 阅读全帖
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)