由买买提看人间百态

topics

全部话题 - 话题: vectoring
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
o*******p
发帖数: 722
1
来自主题: JobHunting版 - C++在vector里找>50的数,怎么找?
bind is more general than bind2nd. You don't need to define your own
function.
vector myvector;
for (int i=1; i<20; i++) myvector.push_back(i*10);
for (vector::iterator results = myvector.begin(); results != myvector.
end(); results++)
{
results = find_if(results, myvector.end(), bind(std::greater(), _1,
50));
cout << *results < }
h****a
发帖数: 70
2
来自主题: JobHunting版 - 自己实现vector
请问有什么好的自己写的vector的code examples吗?我看
有的面经里提到被要求写一个vector class。
谢谢
S**********e
发帖数: 41
3
【 以下文字转载自 Sex 讨论区 】
发信人: SaturdayNite (Show), 信区: Sex
标 题: 包子求助:全是1的vector英语叫什么?
发信站: BBS 未名空间站 (Sun Oct 30 01:06:10 2011, 美东)
发信人: SaturdayNite (Show), 信区: Stock
标 题: 包子求助:全是1的vector英语叫什么?
发信站: BBS 未名空间站 (Sun Oct 30 01:05:24 2011, 美东)
还有全是1的matrix?
全是1的对角阵?
这三个有特殊的称呼吗?英语怎么说?
y*****x
发帖数: 3291
4
来自主题: JobHunting版 - 问个STL的 list和 vector的问题
什么情况下 vector 的 insertion会比 list快?
我觉的在很小SIZE的数据下allocate memory花时间,有可能 list要比 vector慢。
还有什么其他特殊情况下会有这种情况出现吗?
h*******e
发帖数: 1377
5
来自主题: JobHunting版 - 问个STL的 list和 vector的问题
vector如果 相对较大的话, 每次开的空间会很大, 富余空间大,这时候push_back就
不用新开空间了。 另外二楼的vector写的STL对么。。怎么这么奇怪呢。
k***x
发帖数: 6799
6
来自主题: JobHunting版 - 问个STL的 list和 vector的问题
得看是插在什么地方
如果插中间的话,vector很慢;如果是插在尾部的话,其实大多数情况下vector反而快
s********u
发帖数: 1109
7
其实就是leetcode里的Merge k Sorted Lists
输入是一个vector lists,
但是如果用:
priority_queue, comp> heap(lists.begin(),
lists.end());
虽然编译可以过,但会runtime error。
创建一个空的heap,然后一个个push进去。这样的话理论上时间复杂度会从O(k)上升到
O(klogk),因为直接buildheap的效率是比较高的,而每次push则需要logk。
有人用make_heap做,但直接导致整个解法繁琐不少,所以想问问可不可以用
constructor直接解决。
O****L
发帖数: 3353
8
J(ALL 1 MATRIX)
I (DIAGONAL 1)
ALL 1 VECTOR NO SPECIAL NAME JUST VECTOR 1
l*********m
发帖数: 16971
9
wrong.
ones vector: All ones
unit vector: only 1 element is 1
g*****u
发帖数: 14294
10
You are right. The first one is all 1's vector, not unit vector.
w***n
发帖数: 9040
11
$1699 Garmin Vector power meter
dcrainmaker的评测出来了。
http://www.dcrainmaker.com/2013/08/hands-on-garmin-vector.html
i*********5
发帖数: 19210
12
【 以下文字转载自 Tri 讨论区 】
发信人: ironman2015 (IMMT 2013), 信区: Tri
标 题: Why Garmin pro team is not using the vector?
发信站: BBS 未名空间站 (Wed Jul 9 16:55:42 2014, 美东)
Garmin-Sharp is obliged to use the Garmin Vector power-meter pedals,
although most riders are only using the bodies, not the meters themselves
http://forum.slowtwitch.com/cgi-bin/gforum.cgi?post=5156476;sb=
It's an eSs aRe aM, which is a SRM having its logos taped over
Lots of anecdotal evidence on the garmin forums, amazon, and various cyclin... 阅读全帖
b****n
发帖数: 15
13
【 以下文字转载自 Tri 讨论区 】
发信人: ballon (气球), 信区: Tri
标 题: 转让 Xterra Mens Vector Pro Full Suit - Size M
发信站: BBS 未名空间站 (Mon Nov 30 12:36:38 2015, 美东)
转让 Xterra Mens Vector Pro Full Suit, Medium Size.
今年夏天买的,穿过4次开水。没有任何问题。照片请站内私信。$179 shipped in US
不怎么发帖, 如有违版规,请版主告知。谢谢!
w*******g
发帖数: 9932
14
来自主题: CS版 - java Class Vector
actually, his question is different.
he wants to insert in the middle of the vector frequently,
in this case, the Vector object will compact if it is based on Array.
So to be sure, he might want to choose LinkedList class.
b*********n
发帖数: 1258
15
来自主题: CS版 - 如何同时sort 2个vector ?
比如说一个vector x是1,2,3,4,5
另外一个vector y是a,b,c,d,e
我想sort 1,2,3,4,5成5,4,3,2,1,同时a,b,c,d,e成e,d,c,b,a
C++里面我用sort函数来sort x w/ Comp函数f
怎样才可以同时以同样的order来sort y但是却不用Comp函数f呢?
谢谢
z****p
发帖数: 138
16
来自主题: Java版 - 关于Vector的土问题
Vector test=new Vector();
new.add(3);
这两行代码有错么?
总报错,似乎不能放int类型?
谢谢
g*****g
发帖数: 34805
17
来自主题: Java版 - Array of vector, help
Come on, if you want help, provide detailed info like what the error message
is. Probably because you didn't create Vector though.
for(i=0; i<20; i++){
tables[i] = new Vector();
}
m*******o
发帖数: 264
18
来自主题: Java版 - VECTOR一问
怎么没一个人讲明白,VECTOR是动态同步的,所以都一样
可是为什么如果把VECTOR换成ARRAYLIST也是一样的结果?
e****o
发帖数: 76
19
来自主题: Java版 - 问一道关于Vector的题
假设一个Vector存了一些CLASS A 的objects。A 有一个member int b。
如果想把Vector 里所有A的objects that has b==5 remove 掉。 是用for loop还是
用 enumeration? 如果用enumeration, 怎样把object remove 掉, 不能用 iterator
e****o
发帖数: 76
20
来自主题: Java版 - 问一道关于Vector的题
removeAll from newly create vector wont affect the size of the old vector,
even though those (b==5) objects are null now.
F****n
发帖数: 3271
21
来自主题: Java版 - 问一道关于Vector的题
其实你们都对,如果是array不考虑内存肯定是另开一个好
既然是Vector那么没有特殊说明当然要保持原来的OBJECT。
象这种Array-based List Insert / Remove效率本来就低
如果要经常modify就不要用ArrayList, Vector, 用HashSet
或者commons.collections.*
F****n
发帖数: 3271
22
来自主题: Java版 - 问一道关于Vector的题
Insert / Remove还是慢,O(n)就已经是慢的了,
特别在需要经常INSERT / REMOVE的时候。Vector / array主要是iteration快
如果要经常修改,不要用VECTOR/ARRAY,如果不经常修改,经常ITERATE,用。
c*****t
发帖数: 1879
23
来自主题: Java版 - 问一道关于Vector的题

That's not a good approach, because of repeated calling of hashCode () and
lookup of the object in the
hashset which is slow. A better approach is:
final int size = vec.size ();
Vector newVec = new Vector (size);
for (int i = 0; i < size; ++i)
{
A a = (A)vec.get (i); // very fast op due to direct array retrieval
if (a.b != 5) // or whatever filter that indicates keeping the element
newVec.add (a); // very fast op since we have all the capacity set
}
vec.clear (); // very fast op,
m****r
发帖数: 6639
24
这个需要知道vector是怎样implement的。 我看了一下, 里面是一个array。
但是vector本身没有swap, 只有remove和add, 貌似也没有其他的好办法。
除非你直接去改每个card的value。 但是这个应该不是题目的意思吧。
m***x
发帖数: 492
25
来自主题: Programming版 - how to look the values in a vector in VC.NET
When debugging, it only shows the first and last values for a vector.
Any idea to see the values of whole vector?
s****o
发帖数: 18
26
如果有N个相同维数的向量,how to efficiently find those subsets whose members
are all orthogonal to each other?
E.g. if we have vectors X_1, X_2, ..., X_n
we may find in (X_1, X_5, X_7) all vectors are orthogonal, and we need all
other subsets.
Any references?
Thank you in advance!
t****t
发帖数: 6806
27
来自主题: Programming版 - STL vector的clear如何强制归还系统?
use the swap trick, e.g.
vector a; // that you want to release
vector().swap(a);
s*****n
发帖数: 1279
28
来自主题: Programming版 - 关于std::vector的一个很简单的问题
在vector中push_back function参数如下:
void push_back(
const Type& _Val
);
如果我有如下:
vector try;
double x=0;
for (int i=0; i<10; i++; )
{
x=0.5*i;
try.push_back(x);
}
最后try中的值会都是一样的吗(4.5)? 因为每次传得都是reference? 还是实际上做了
copy?
b***y
发帖数: 2799
29
来自主题: Programming版 - [合集] 如何同时sort 2个vector ?
☆─────────────────────────────────────☆
babyfacenan (黑土) 于 (Wed Feb 20 01:47:45 2008) 提到:
比如说一个vector x是1,2,3,4,5
另外一个vector y是a,b,c,d,e
我想sort 1,2,3,4,5成5,4,3,2,1,同时a,b,c,d,e成e,d,c,b,a
C++里面我用sort函数来sort x w/ Comp函数f
怎样才可以同时以同样的order来sort y但是却不用Comp函数f呢?
谢谢
☆─────────────────────────────────────☆
kukutf (五脚蟹★酷酷豆腐) 于 (Wed Feb 20 02:06:42 2008) 提到:
偷懒的办法,用map做
map,建一个,然后逐个读出来。

☆─────────────────────────────────────☆
coconut (向唐僧大师学习中) 于 (Wed Feb 20 02:21:49 2008) 提到:
std:
b***y
发帖数: 2799
30
☆─────────────────────────────────────☆
babyfacenan (黑土) 于 (Wed Feb 27 22:36:40 2008) 提到:
本来用了java里的vector
可是只能放object进去,不能用primitive types
用primitive types wrapper的话,又不能修改值
请教大家一下:java里还有什么可以替代vector的吗?
谢谢
☆─────────────────────────────────────☆
randomtiger (tiger) 于 (Wed Feb 27 23:17:06 2008) 提到:
ArrayList<>
import java.util.*;
class test
{
public static void main(String[] s)
{
List x = new ArrayList();
x.add(2);
x.add(3);
x.s
j******y
发帖数: 700
31
来自主题: Programming版 - [求教]high dimensional vector visulization
现在手头上有一些high dimensional vector [n1, n2, n3, .... n90000], 维数大概
90000,现在想用软件简单的visulize一下这些vector看看有没有可能找到clusters,不
知道什么软件可以做这样的事情,请大家指教
j******y
发帖数: 700
32
来自主题: Programming版 - [求教]high dimensional vector visulization
您说的是PCA吗?好的我会试试
那请问一下用什么软件处理比较好呢?我用MATLAB做,但是一旦vector多了,比如说上
百个,matlab就显示out of memory了,不知道是我一次load了太多的vector还是什么
,有没有什么解决方法呢?
谢谢
还有一个相关问题就是MDS和PCA哪一个好些呢?
d****n
发帖数: 130
33
来自主题: Programming版 - vector::iterator不对
我定义了function template, 有个参数是iterator:
template
void fun(vector::iterator it)
{
}
但是编译通不过,说vector::iterator不是一个TYPE.
S**I
发帖数: 15689
34
vector a(10);
for(...)
a[i] = ...;
const vector b(a);
d**t
发帖数: 183
35
来自主题: Programming版 - Remove elements from multiple vectors in C++
vector name;
vector age;
How do I remove all the persons old than 30 from both name and age? I can do
it in a loop, but I am wondering if there is a more elegant way.
Thanks,
O*******d
发帖数: 20343
36
来自主题: Programming版 - Question about vector as a class member
Vector or Deque? Vector的缺点需要Deque来弥补。
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1069897449&id=1073086407
h*****0
发帖数: 4889
37
来自主题: Programming版 - C++ vector 到底能多大
...3G的vector……你内存够吗?
啥程序需要这么大的vector?
h******6
发帖数: 5
38
来自主题: Programming版 - 问个 std::vector 的基本问题
下面的这段代码为什么会出错? 谢谢!
#include
#include
class Stack{
public:
Stack();
~Stack(){delete[] _buffer;}
private:
const int _capacity;
int _size;
int *_buffer;
Stack & operator = (const Stack& rhs );
};
Stack::Stack():_capacity(10), _size(0){
_buffer = new int[_capacity];
}
int main(){
std::vector stackArray(3);
}
p****o
发帖数: 1340
39
来自主题: Programming版 - 问个 std::vector 的基本问题
std::vector uses copy to initial the vector: basically the same Stack object
is copied three times to fill stackArray.
it is efficient for most cases, while failed here...
c**********e
发帖数: 2007
40
来自主题: Programming版 - question on reserve() in vector container.
Code:
vector x;
x.reserve(3);
x[0]=5; // x.push_back(5);
cout << "x[0]=" << x[0] << endl;
x.reserve(10);
cout << "x[0]=" << x[0] << endl;
The output is x[0]=5 and x[0]=0. So it is not OK to assign vector values
with x[0]=5?
Using x.push_back(5), there is no such problem. I get x[0]=5 and x[0]=5. So
it is always safe to use push_back(). The question is, why x[0]=5 does not
work? Thanks.
d****p
发帖数: 685
41
来自主题: Programming版 - question on reserve() in vector container.
the reason why your second x[0] yields 0 is the reserve operation
reallocated memory for your vector and thus &x[0] changed. Since the length
of the vector is still 0, the first value (5) won't be copied to new
location.
If you use push_back and reserve, the &x[0] will change too; but the
implemention however will copy the value of the 1st element to the new
location.

So
t*****t
发帖数: 52
42
来自主题: Programming版 - C++ vector 一边遍历一边删
用list是一个方法,还有一个方法是用另外一个vector, 符合条件的不管,不符合的
push_back到另一个, 最后交换两个vector的指针, OK.
r*******m
发帖数: 109
43
来自主题: Programming版 - C++ vector 一边遍历一边删
It's more efficient for vector since remove one by one will move things
around. Remove_if does not change the size of the vector. But I agree it's
not intuitive.
Funny it was once asked during an interview.
d*********8
发帖数: 2192
44
来自主题: Programming版 - C++ vector 一边遍历一边删
需要在VECTOR中间删除元素,你首先要问自己为啥用的是VECTOR.
r********3
发帖数: 2998
45
来自主题: Programming版 - C++ vector 一边遍历一边删
因为vector随机访问速度很快,基本就是1,2条指令。set的话,即便是hashset所谓O(1
)也是几十条指令。至于TreeSet这些都是Log(N)的复杂度了。
另外最重要的一点,vector里面的内存是连续分配的。在分配和回收上,分散的set是
无法比拟的。
t****t
发帖数: 6806
46
来自主题: Programming版 - CodeBlocks cannot display vector in Watches
gdb对STL的支持一般, 但是常见的vector什么的还是可以用的, 别的distro我不知道,
fedora的libc++里面是有pretty-printer的, 打印个vector打印个string什么的不成问题
S**I
发帖数: 15689
47
来自主题: Programming版 - static vector 怎么 initialize ?
you can initialize an array, then use that array to initialize the vector:
string a[] = {"ABC", "DEF", "GHI"};
vector A::s(a, a+sizeof(a)/sizeof(a[0]));
h**********c
发帖数: 4120
48
来自主题: Programming版 - static vector 怎么 initialize ?
好像这样吧
some.h
class c {
static std::vector sv;
public:
}
some.cpp
std::vector c::sv ;
最少visual c++ 是这样,
如何解释呢,header 里的东西不会成为memory instance,只有cpp 里才可以。
S**I
发帖数: 15689
49
来自主题: Programming版 - static vector 怎么 initialize ?
you can initialize an array, then use that array to initialize the vector:
string a[] = {"ABC", "DEF", "GHI"};
vector A::s(a, a+sizeof(a)/sizeof(a[0]));
h**********c
发帖数: 4120
50
来自主题: Programming版 - static vector 怎么 initialize ?
好像这样吧
some.h
class c {
static std::vector sv;
public:
}
some.cpp
std::vector c::sv ;
最少visual c++ 是这样,
如何解释呢,header 里的东西不会成为memory instance,只有cpp 里才可以。
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)