由买买提看人间百态

topics

全部话题 - 话题: pointer
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
g****u
发帖数: 252
1
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
smart pointer龌龊的地方是在拷贝的时候发生的一系列说不清道不明的事情. RAII本
身是反拷贝的.
t****t
发帖数: 6806
2
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
smart pointer不是为了给猴子用的....
l*********s
发帖数: 5409
3
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
well, say you have to pass an async callback some object, how RAII can help
you avoid smarter pointer in this case?
f******y
发帖数: 2971
4
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
啥也别说了,赶快去学学smart pointer再来评论吧。
b*******s
发帖数: 5216
5
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
现在的smart pointer设计得非常巧妙
很喜欢
p*****y
发帖数: 1049
6
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
哥来评论一下,
如果你在同一个花括号用new 和 delete, 仍然有内存泄露的风险,因为程序有可能
throw exception
也就是为什么要用smart pointer
g****u
发帖数: 252
7
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
上面将了, 用scopeexit. 话所什么情况需要往容器里放几万个pointer指向的dynamic
objects. 我觉得应该有更好的设计方案.
a***n
发帖数: 538
8
来自主题: Programming版 - C++的smart pointer注定是个二流的东西
除了shared pointer比较恶心,其他的都还好吧。
N******K
发帖数: 10202
9
把std的smart pointer 继承了, 然后加入一个 object graph ? 类似于写一个GC...

还是有现成的方法?
k**********g
发帖数: 989
10

..
Yes, sort of.
The essence of this problem is to answer the question: "when is it safe to
permanently delete something".
If you answer is: "it is safe to delete it if it is theoretically impossible
to cause a problem by deleting it", then your answer is essentially what is
known as "reachability". Something that is not reachable is like
Schrodinger's cat; nobody knows if it is dead or alive.
I can think of three approaches. The first two are practical; the third one
is too advanced to be impl... 阅读全帖
t****t
发帖数: 6806
11
早就说过C++ 的smart pointer跟GC没啥关系, 就是RAII而已.
N******K
发帖数: 10202
12
我什么时候说过我是c++ smart pointer的专家了?
l***l
发帖数: 41
13
来自主题: Programming版 - 什么时候使用c++ smart pointer?
工业界的惯例是怎样的?
如果用c++去面试的话,用smart pointer是不是更好点?
t****t
发帖数: 6806
14
来自主题: Programming版 - 什么时候使用c++ smart pointer?
再说一遍, C++的所谓smart pointer和GC基本上没有关系, 实现的是RAII以及
exception safe
n****1
发帖数: 1136
15
来自主题: Programming版 - 什么时候使用c++ smart pointer?
如果采用RAII模式, 而且constructor以内所有指针都用shared_ptr, constructor外的
所有指针都强制使用weak_ptr,是否可以彻底避免cyclic pointer的问题?
g*********e
发帖数: 14401
16
来自主题: Programming版 - 什么时候使用c++ smart pointer?

你说的是auto_ptr 出了scope自动call destructor
smart pointer 一般指的是shared_ptr 有refCount的 出了scope不一定会destruct
N******K
发帖数: 10202
17
来自主题: Programming版 - 什么时候使用c++ smart pointer?
事务性质的 比如把数据从A处搬到B处 这种体力活 用java 或者matlab等有GC的
计算性质的 用c++ 当然smart pointer肯定要用了
你要担心内存 就把c++的搞成独立进程
主进程用有GC的比如matlab或者java
c++进程运行完就关闭 哈哈 啥都清理了
进程之间通过文件交流信息 可以把内存开辟一块为虚拟硬盘
我最近就这么搞
k**********g
发帖数: 989
18
来自主题: Programming版 - 什么时候使用c++ smart pointer?

Anything private within a class (never shared with outside) should use
unique_ptr.
Cyclic pointer problem is solved by deliberate design effort on the class
interaction diagram (unrelated to inheritance). As long as there is a "top
level object" which has ownership, a solution can be found.
RAII 就是所谓 Linear Stack ,因此不能支持 capture by reference 的 closure(
但仍支持capture by value (copy) )。 用 C++11 lambda 的时候还得用 shared_ptr。
http://en.wikipedia.org/wiki/Closure_(computer_programming)
http://en.wikipedia... 阅读全帖
p*****2
发帖数: 21240
19
否则就可以放心传reference/pointer了。设计确实不如FP优美。
a***u
发帖数: 14
20
那位大虾讲述一下file descriptor 和 file pointer 的联系,有什么function可以使两
者互相转换?谢谢!
p***n
发帖数: 344
21
来自主题: Computation版 - [转载] matlab里面移动指针pointer问题
【 以下文字转载自 Science 讨论区,原文如下 】
发信人: plain (拳头底下出孝子), 信区: Science
标 题: matlab里面移动指针pointer问题
发信站: Unknown Space - 未名空间 (Sun Mar 20 19:00:20 2005) WWW-POST
用fopen打开一个binary 文件,想迅速找到(i,j)位置的元素。
虽然可以用fgetl一行一行找,但是好象比较麻烦,因为还要循环语句,还要算好位置。
有没有其他的function可以用来迅速移动指针?类似于 function(i,j)之类的命令
谢谢
j**u
发帖数: 6059
22
☆─────────────────────────────────────☆
GentlemanBug (Lucky bug) 于 (Fri May 4 13:51:25 2007) 提到:
如果这个pointer不是NULL的话?
☆─────────────────────────────────────☆
OverCloud (天马行空) 于 (Fri May 4 16:34:49 2007) 提到:
没有办法。
b**g
发帖数: 588
23
来自主题: Archery版 - Spike你不来,8 pointer 你哪?
my 8 pointer
w*******y
发帖数: 60932
24
Link:
http://www.meritline.com/2-in-1-mini-red-laser-pointer-with-led-falashlight---p-37033.aspx
Coupon code:MLCK4004170626HPL1
Deal starts today at 9:00AM PDT
[countdownn="06/26/2010 8:00AM"]Until Deal Starts[/countdown]
w*******y
发帖数: 60932
25
Newegg
Kensington K33374US Wireless Presenter with Laser Pointer
$29.99 - $20 Rebate
= $9.99 with free shipping
*starts 1 PM PST*
Next lowest on Google Products is $40
w*******y
发帖数: 60932
26
Meritline
3-in-1 LED Flashlight with Laser Pointer (compact size)
99 with code MLCK600403072363NL1
shipped
w*******y
发帖数: 60932
27
Meritline has 2 in 1 LED/Red Laser pointer in stainless steel for $0.99
shipped.
Link:
http://www.meritline.com/stainless-steel-push-led-infrared-flashlight---p-46793.aspx
w*******y
发帖数: 60932
28
5mW Green Laser Pointer Pen:
http://www.shop4tech.com/item8948.html
17% off coupon code TOP17 expires 09-05-2010
Specification
* Max Output: <= 5mW
* Wave Length: 532nm
* Output wave: Continuous wave
* Class: Class 3A (Class 3A rated Samsung Laser Chip)
* Power: 2 x AAA battery (now included in the gift box)
* Time to reach full laser strength: 0 to 60 seconds
* Comparison: About 2 times brighter than the 5mW green laser
* Length: 5.59 "
* Width: 0.51 "
*
w*******y
发帖数: 60932
w*******y
发帖数: 60932
30
$0.59 w/Code: MLCK18897410 1480AL1 For First 1000 Orders
$1.99 w/Code: MLCK18897410 1433A After 800 Orders
Link:
http://www.meritline.com/led-laser-pointer-key-chain-torch-974---p-35285.aspx?source=nl101014&hq_e=el&hq_m=2065644&hq_l=81&hq_v=16e69ced6f
w*******y
发帖数: 60932
31
$0.59 w/Code: MLCK18897410 1480AL1 For First 1000 Orders
$1.99 w/Code: MLCK18897410 1433A After 800 Orders
Link:
http://www.meritline.com/led-laser-pointer-key-chain-torch-974---p-35285.aspx?source=nl101014&hq_e=el&hq_m=2065644&hq_l=81&hq_v=16e69ced6f
w*******y
发帖数: 60932
32
Ok, I waited to post on this deal because I wasn't sure if the retailer was
reliable or not. This is for the Rii Mini, without the bluetooth adapter,
which you can get for few bucks at meritline anyways. If you don't know
about the keyboard yet, you can check out the Rii Mini video here:
Link:
http://www.engadget.com/2010/03/05/rii-mini-wireless-keyboard-is-perfect-for-your-htpc-not-your-wi/
Video was for the RF unit.
It's the best HTPC keyboard I can find, and keep in mind, this is the
blueto... 阅读全帖
w*******y
发帖数: 60932
33
Staples
APC Back-UPS ES 350VA 6-Outlet Power-Saving UPS:
http://www.staples.com/product_733724
$20
Targus Notebook Wireless Presenter with Laser Pointer:
http://www.staples.com/product_512802
$10
Free ship-to-store
w*******y
发帖数: 60932
w*******y
发帖数: 60932
35
Multifunctional (7-in-1) Credit Card Size Tool With Seven Features,
Magnifier, Focus Lens, Ball Pen, Compass, LED Light, Laser Pointer and Money
Detector (More Details)
Coupon Code :MLCK403150012675NL1 limit 800 uses
Link:
http://www.meritline.com/7-in-1-credit-card-size-tool-set---p-5
w*******y
发帖数: 60932
w*******y
发帖数: 60932
37
From Meritline today's email
Da Link:
http://www.meritline.com/3-in-1-red-laser-pointer-ball-point-pe
Coupon Code: MLCK5A3F0QNL1
w*******y
发帖数: 60932
g******y
发帖数: 2517
39
Rii Mini Wireless Keyboard (Built-in TouchPad/Laser Pointer) - Black,35%折扣
http://amzn.to/uC3AnC
进入页面后,选择Pink or Silver,然后点右侧的"View Lightning Deal"
w*******y
发帖数: 60932
40
High power and high performance 1500mW Levin series blue laser pointer is
available now at $299.99 ONLY!
Find more details at LaserTo and enjoy this high performance laser now!
g******y
发帖数: 2517
41
Rii Mini Wireless Keyboard (Built-in TouchPad/Laser Pointer) - Black,42%折扣
http://amzn.to/uC3AnC
f**d
发帖数: 768
42
来自主题: 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: ... 阅读全帖
p*****2
发帖数: 21240
43
来自主题: JobHunting版 - 今天计划做20题

Id Question Difficulty Freqency Data Structures Algorithms
1 Two Sum 2 5
array
set
sort
two pointers
2 Add Two Numbers 3 4
linked list
two pointers
math
3 Longest Substring Without Repeating Characters 3 2
string
hashtable
two pointers
4 Median of Two Sorted Arrays 5 3
array
binary search
5 Longest Palindromic Substring 4 2
string
6 ZigZag Conversion 3 1
string
7 Reverse Integer 2 3
math
8 ... 阅读全帖
j*****g
发帖数: 16
44
来自主题: Programming版 - int F::*x = &F::x是什么意思?
(From "Thinking in C++")
Pointers to members
A pointer is a variable that holds the address of some location. You can
change what a pointer selects at runtime, and the destination of the pointer
can be either data or a function. The C++ pointer-to-member follows this
same concept, except that what it selects is a location inside a class. The
dilemma here is that a pointer needs an address, but there is no “address”
inside a class; selecting a member of a class means offsetting into that
class. Y... 阅读全帖
p*****2
发帖数: 21240
45
来自主题: JobHunting版 - 我的面试题总结
好多人问,我就发到这里吧。
面试题的构成和分类
首先声明一下,这里的面试题主要所指数据结构和算法的题目,题目的分析集中在
Leetcode上面的题目上。
我认为一道面试题由以下几个方面组成的
Question
Data structure in question
Data structure in solution
Algorithm in solution
Coding
题目:非常关键,一个题目通常有一些相应的变形题目,同一个题目可能有不同的要求
。比如时间复杂度,空间复杂度的要求,比如recursive,
iterative的要求。而根据题目的变形与要求,可能会极大的影响到你能够采取的数据
结构和算法。
问题中的数据机构:问题中有可能带数据结构,有可能没有数据结构,有可能是可以自
定义数据结构
解决方案中的数据结构:可以是in-place的,也就是利用已有的数据结构,也可能是创
建新的数据结构。新的数据结构跟已有的数据结构没有必然的联系,而很多问题都是一
题多解,可能采取不同的数据结构。
算法:一般来说,当解决方案中的数据结构确定以后,算法也就确定了。同样,一旦解
决方案的算法确定... 阅读全帖
p*****2
发帖数: 21240
46
来自主题: JobHunting版 - 我的面试题总结
好多人问,我就发到这里吧。
面试题的构成和分类
首先声明一下,这里的面试题主要所指数据结构和算法的题目,题目的分析集中在
Leetcode上面的题目上。
我认为一道面试题由以下几个方面组成的
Question
Data structure in question
Data structure in solution
Algorithm in solution
Coding
题目:非常关键,一个题目通常有一些相应的变形题目,同一个题目可能有不同的要求
。比如时间复杂度,空间复杂度的要求,比如recursive,
iterative的要求。而根据题目的变形与要求,可能会极大的影响到你能够采取的数据
结构和算法。
问题中的数据机构:问题中有可能带数据结构,有可能没有数据结构,有可能是可以自
定义数据结构
解决方案中的数据结构:可以是in-place的,也就是利用已有的数据结构,也可能是创
建新的数据结构。新的数据结构跟已有的数据结构没有必然的联系,而很多问题都是一
题多解,可能采取不同的数据结构。
算法:一般来说,当解决方案中的数据结构确定以后,算法也就确定了。同样,一旦解
决方案的算法确定... 阅读全帖
l*********y
发帖数: 142
47
来自主题: JobHunting版 - 攒人品之facebook电面面经
#include
#include
#include
#include
#include
#include
#include
using namespace std;
class Counter {
public :
Counter() {
counter = 0;
}
void increment() {
counter++;
}
void decrement() {
counter --;
}
int getValue() {
return counter;
}
private:
int counter;
};
class COWString {
public:
COWString() {
pointer = NULL;
rc = new Counter();
}... 阅读全帖
b****n
发帖数: 464
48
为什么呢?
第1步: pointer 1 at node 1; pointer 2 at node 1;
第2步: pointer 1 at node 2; pointer 2 at node 3;
第3步: pointer 1 at node 3; pointer 2 at node 5;
第4步: pointer 1 at node 4; pointer 2 at node 2; (结束)
还是说,至此不算结束,还继续?
第5步: pointer 1 at node 5; pointer 2 at node 4;
第6步: pointer 1 at node 6; pointer 2 at node 6;
答案其实还有一句,就是说pointer 2不一定要只跳一格,可以每次跳n (n>1)格,
那么,是不是说,根据圈的大小,有时候要绕比较多圈,两个pointer才刚好遇得上?
而且,反正有圈,两个pointer如果遇不上,就会一直转下去?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)