由买买提看人间百态

topics

全部话题 - 话题: pointer
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
a**********0
发帖数: 422
1
来自主题: JobHunting版 - copy list with random pointer 老出错
我的思路是
复制每个节点 插在每个节点的后边
然后每个都copy random pointer
然后分开两个链表
我为什么第一次没有通过呢 因为第一次只是构建了一个新链表 但是把原来的破坏了

random
a**********0
发帖数: 422
2
来自主题: JobHunting版 - copy list with random pointer 老出错
/**
* Definition for singly-linked list with a random pointer.
* class RandomListNode {
* int label;
* RandomListNode next, random;
* RandomListNode(int x) { this.label = x; }
* };
*/
public class Solution {
public RandomListNode copyRandomList(RandomListNode head) {

if(head == null)
return null;

if(head.next == null){
RandomListNode result = new RandomListNode(head.label);
result.next = null;
if(head.random != null)
re... 阅读全帖
g****v
发帖数: 971
3
来自主题: JobHunting版 - 请教下copy list with random pointer
我的代码在我自己机器上没问题,但leetcode上连最简单的case都通不过。
比如 [-1, #] 都没通过。
实在是找不出问题,请大家看看。
----------------------------------------------------------------------------
------------------
RandomListNode *copyRandomList(RandomListNode *head) {
if(head == NULL) return NULL;
RandomListNode *copyhead = new RandomListNode(head->label);
copyhead->random = head->random;
RandomListNode *ori = head->next;
RandomListNode *oritemp;
head->next = copyhead;
RandomListNode ... 阅读全帖
g****v
发帖数: 971
4
来自主题: JobHunting版 - 请教下copy list with random pointer
lc给出的output是:
Next pointer of node with label -1 from the original list was modified.
n*******t
发帖数: 6
5
可以用两个function pointer之差来indicate 系统stack 是upward 还是downward吗?
k****5
发帖数: 546
6
function pointer is just the memory address of the function image in code
section. Once loaded in memory, it is not changed.
there can be more than one instance of one function on the stack, either
direct or indirect recursion.
Allocate some heap and stack variables, check their addresses to get the
idea of memory layout of heap&stack.
class is about data layout, not about stack.
check any compiler book about runtime structure etc.
k****5
发帖数: 546
7
once you take the address of one function, I don't think it should be
optimized out like inlining etc. But the compiler usually choose to not save
frame pointer on stack by default. But that does not mean there's no such
function in memory in running time.
a**********0
发帖数: 422
8
题目很简单 思路就是 level order traverse 其间每一层除了最后一个node 其他的
node的next都指向本层的下一个 最后一个node的next指向null
不过老过不了OJ 报错 而且我自己在eclipse上跑了一下 发现自己跑的结果和报错的情
况不一样 难道是oj错了
/**
* Definition for binary tree with next pointer.
* public class TreeLinkNode {
* int val;
* TreeLinkNode left, right, next;
* TreeLinkNode(int x) { val = x; }
* }
*/
public class Solution {
public void connect(TreeLinkNode root) {

if(root == null)
return;

LinkedList que... 阅读全帖

发帖数: 1
9
来自主题: Living版 - Target卖 presentation pointer吗
Target卖 presentation pointer吗?Staple有,太贵了,还远。
c****i
发帖数: 40
10
来自主题: shopping版 - 最近有laser pointer的deal么?
想买既有laser pointer又能同时帮ppt翻页的那种。谢谢!
c*****r
发帖数: 2426
11
来自主题: Basketball版 - My idea about 3-pointer
in recent years, as the players have gotten stronger and stronger, also the
shooting skills have been more and more optimized, the shooting range is
greatly enhanced. Maybe this is not going to be something we expect most, but
we are definitely going to see more and more 3-pointers.
In a shooter's point of view, 22 feet is not much different than 18 feet, of
course maybe the accuracy would drop a little since it's a bit far, but hey,
if I take one or two steps to the outside then I would get a m
m********n
发帖数: 2995
12
来自主题: Fishing版 - Lucky Craft pointer
good for suspending or sluggish fish, well crafted, too.
Pointer is a suspending jerk bait (or, in warm water, slow sinking).
t*******y
发帖数: 10477
13
发信人: NightRunner (子夜狂奔), 信区: GunsAndGears
标 题: Re: The 11 Pointer
发信站: BBS 未名空间站 (Sat Nov 6 22:13:15 2010, 美东)
射完就看见血从身上出来,跑了将近100yard, 倒在小河沟,一路上bloodtrail成弥漫飞
溅型,非常清楚。
射中了脾和肝,照片上的伤口是entry wound, exit wound低很多,而且靠前点。我在
树上6yard高,它离树水平距离也就8yard.
t*******y
发帖数: 10477
14
发信人: NightRunner (子夜狂奔), 信区: GunsAndGears
标 题: Re: The 11 Pointer
发信站: BBS 未名空间站 (Sat Nov 6 22:35:26 2010, 美东)
上周末在Virginia Beach, 白沙滩上,shotgun瞄好了一个doe,犹豫要不要打,人家跑
了。
今天早上天蒙蒙亮,树下10米一个doe,我怎么都从瞄准镜里找不到,直到人家离去,发
现是自己呼出的水蒸气导致瞄准镜结雾了,然后就是看见100米远处一队鹿排着队过河
,接着一上午,又一下午,居然再也没有见着鹿,日落时分,此11pointer火急火燎地
快步走来,闻了闻我挂的母鹿尿,然后更加着急地沿着早已被我勘探清楚的deer trail
赶路,距我8米处,一箭解决,当即就看见伤口喷血,插在地上的箭的三个fletching全
部都
是红黑的。
N*********r
发帖数: 1190
15
来自主题: GunsAndGears版 - The 11 Pointer
终于进阶到11 Pointer club.
Today. Archery shot at 8 yards
b**s
发帖数: 4571
16
来自主题: GunsAndGears版 - The 11 Pointer
恭喜进阶到11 Pointer club!!!
N*********r
发帖数: 1190
17
来自主题: GunsAndGears版 - The 8 Pointer
没那个壮,那个怎么说也是个11 pointer, 这个是8,还跟人打架打断了一个point
今年鹿已经到10了,主要是archery 6个。
N*********r
发帖数: 1190
18
来自主题: GunsAndGears版 - 圆满了,刷新记录,12 pointer
I shot my 11 pointer at 5 yards. 打猎,枪法只是一小部分。 冷静和选择时机很重
要。
X*U
发帖数: 5518
19
我家有好多laser pointer啊,红绿蓝的,买大的,其实都差不多
l*******r
发帖数: 4028
20
来自主题: pets版 - English pointer真能跑
今天去dog park, 我家是只接近四个月的Doberman, 玩了半小时就剩我家一条狗了,正
愁怎么玩,来了一只敏捷矫健的狗,跑起来象猎豹,问主人才知道是English pointer
。这条狗很会玩,看我家狗接近就开始加速,中途还会突然变向,两条狗基本没有身体
接触,但是运动量巨大。这比跟别的狗扒来扒去玩的健康多了。
这次忘记了拍照,下次碰到再补上。
z******o
发帖数: 3285
21
来自主题: pets版 - English pointer真能跑
六个月太小 还不会跑步呢 即使狗 跑步的技巧也是随着锻炼提高的
pointer还有greyhound的血统呢 但那个老头嘴应该是bull terrier来的
养这种狗需要提高很多时间空间让他奔跑打猎啥的 图啥呢
我现在天天带mango跑步都够我受的了
r*****a
发帖数: 27155
22
来自主题: pets版 - English pointer真能跑
应该都是为了打猎吧,据说pointer在家里的时候很calm
黑妞到现在跑步都是puppy样
m**********8
发帖数: 1250
23
帮忙推荐一个不用纽扣电池的LASER POINTER吧,最好是可以充电或者用5/7号电池的。
谢!
现在用的是用纽扣电池的,用不了两天就没电了,太不环保。
a***y
发帖数: 19743
24
according to Macworld
"If you press and hold on the screen, a “laser pointer” effect appears on
the external display—very slick."
d******i
发帖数: 5
25
I am a Java beginner, doing homework to make a parser. I want to know how to
find the number of funciton pointers in Java file?
thanks, gao shou!
K*****n
发帖数: 65
26
来自主题: Programming版 - C++ pointer problem
Are you sure &theZoo[k] gives an animal pointer???
B********s
发帖数: 3610
27
I have a socket connection between a client and a server. Now I want to send
a structure containning a pointer pointed to an int array(which indeed is
what i want to send).How am I supposed to do this? Thanks.
e******d
发帖数: 14
28
来自主题: Programming版 - Why Avoid array indexing. Use pointers.
Code optimization 有这么一条 Avoid array indexing, Use pointers. 为什么呢?不需要再算地址了?
还有 Use int (natural word-size of the processor) to store flags rather than char or short。就因为alignment?
o**f
发帖数: 76
29
来自主题: Programming版 - Question: Given a pointer to a function
Question: Given a pointer to a function, can you find out which function it
is? Thx in advanced!
Example:
typedef void (*foo)();
void abc();
... ...
foo f_ = abc;
... ...
now if f_ is used later, can we tell its name is "abc"?
g***l
发帖数: 2753
30
来自主题: Programming版 - ask a simple question about int pointer.
I was asked such a question: how to determine the size of memory of the int
pointer pointed? for example
int GetTheSizeofMemory(int *buffer)
{
int size;
//enter your code here, to calculate the memory size of buffer point to.
return size;
}
we can not use sizeof(buffer) to get the value, how should we do?
thanks.
t*r
发帖数: 26
31
来自主题: Programming版 - ask a simple question about int pointer.
I have done it before, not in my dream.
There are simple "hack" methods to find out the memory block size associated
with a pointer. It won't work across all compilers/platforms.
t****t
发帖数: 6806
32
来自主题: Programming版 - C++: pointer to members
grab a book and read: pointer to member
w***g
发帖数: 5958
33
对。指call function back。一般情况下调用某个功能传一些参数进去就足够了,但是
有时光参数不够,就要传function进去。比如一个算数值积分的程序,就需要传进去一
个被积函数。至于"call back"这个名字,就是美国人打电话时说的"call back",可能
对中国人来说不是很熟悉。

function pointer.
D*******a
发帖数: 3688
34
来自主题: Programming版 - dereference a NULL pointer in C
this is about null segment selector, not null pointer.
segmentation fault is generally caused by accessing non-existant memory or
denied access.
r*********r
发帖数: 3195
35
来自主题: Programming版 - pointer to function
there are implicit type conversions between a function name and
the corresponding function pointer both ways.
&, * are therefore both optional.
c**a
发帖数: 316
36
可以用 swap 来交换 pointer 和 iterator 吗?
b***y
发帖数: 2799
37
来自主题: Programming版 - [合集] what's the trick of passing pointers
☆─────────────────────────────────────☆
ruisher (aa) 于 (Sat Aug 27 23:26:33 2005) 提到:
I created a vector of pointers to obejcts
std::vector< student* > studentVec;
then write
read_in_student_info(std::vector & studentVec)
{
........
basically, just build up and fill up the vector
.....
}
when it returns back to the main function, then I tried to print out each
element, it works fine.So I just assume this vector is already exist.Then I
call
another subroutine which I want to use th
c**a
发帖数: 316
38
来自主题: Programming版 - Pointer to iterator?
怎么把 pointer 转化成 iterator 呢?
string s("life sucks.");
string::size_type pos = 3;
string::iterator it = &s[pos]; // error!
string::iterator it = s.begin() + 3; //not pretty....
c**a
发帖数: 316
39
来自主题: Programming版 - Pointer to iterator?
。。。
pos 就根本不是 pointer。
vector v(10);
char* p = &v[5];
vector::iterator it = p ; // error.
vector::iterator it = v.begin() + p - &v[0];
// now, it is ugly.
m*****r
发帖数: 130
40
来自主题: Programming版 - deque的pointer和reference是怎么回事?
pointer是那个指向单个element的,你两头插入后,这个poiner还是正确的,但是
iterator有可能不对了,因为end和begin变了。reference同理。
你可以想象这个deque是一个array实现的,头尾在插入后会变。

made
container
a
v*****r
发帖数: 2325
41
来自主题: Programming版 - pointer to class, which class?
C is derived from from base class B
p is a pointer to class B
how to find out p point to B or C?
J*****n
发帖数: 4859
42
比如我有一个function pointer f
double (*f) (const double& p, const double& q=0);
我希望另一个函数g调用它:g(f),那么g的定义该如何写?
另一个问题是如果f的参数个数未知,那么g又该如何写?
谢谢。
t****t
发帖数: 6806
43
the extra parameters of f() is for f() only, right? you encapsulate the
extra parameters WITH function pointer f, and make it an object. the object
may inherit from a common type and g() call f() through virtual functions;
or the object could be unrelated and templated g() call f() through a common
generic interface.
b******a
发帖数: 215
44
来自主题: Programming版 - 请教一个const pointer的问题
cptr是个pointer啊,不是3.14159。
J*******g
发帖数: 381
45
来自主题: Programming版 - 请教一个const pointer的问题
我还是没写对。 请问一下,指向const的 pointer能够直接赋一个常数初始化吗?
H*M
发帖数: 1268
46
来自主题: Programming版 - about STL functor and function pointers
yeah sorry my mistake
it is in cstdlib
can I conculde that all STL functions are fine with functors, and some are f
ine with function pointers at the same time?
z***e
发帖数: 5393
47
来自主题: Programming版 - about STL functor and function pointers
almost right.
c++ programming language上说stl function只是指望你给的那个能够执行 operator(
) (...)的运算,不管是function pointer还是functor.

f
g***8
发帖数: 27
48
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
iterator is a constructed object which behave like a pointer
z****e
发帖数: 2024
49
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
Book Exploring C++
Publisher Apress
DOI 10.1007/978-1-4302-0352-0
Copyright 2009
ISBN 978-1-59059-749-1 (Print) 978-1-4302-0352-0 (Online)
Part Part 4
DOI 10.1007/978-1-4302-0352-0_60
Pages 567-580
Subject Collection Professional and Applied Computing
SpringerLink Date Saturday, February 07, 2009
我就google随便一搜,
其中一句:
An iterator can ensure that it does not advance past the end of a container.
Thus, iterators are smart pointers because they can be really, really smart
d****p
发帖数: 685
50
来自主题: Programming版 - c++ interview: iterator 和 pointer区别?
iterator for certain containers (eg vector> is implemented as raw pointer -
you can think as:
template
class Iterator
{
....T* _M_current;
}
After optimization is turned on, the thin wrapper will be thown away by
compiler and you will have the
same raw metal code.
For example, you have two functions:
int foo1(std::vector::const_iterator intItr)
{ return *intItr + 1; }
and
int foo2(const int* intPtr)
{ return *intPtr + 1; }
Both functions generate the around same assembly snipet:
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)