I cant find any sorting function in the java API for vectors.
Collections.sort is only for List and not for Vector
I dont want to write my own sorting algo because I think java should implement this
Im looking for something like, class ClassName implements Comparator ...
ClassName cn; sort(cn);
...
It seems as though every time I see a mention of separate chaining in a hash table, a linked list is used as the data structure to store items with collisions. Why is this? For instance, why couldn't you use a vector/array data structure?
...
How can I filter an array in Java?
I have an array of objects, for example cars:
Class:
public class Car{
public int doors;
public Car(int d){
this.doors = d;
}
}
Use:
Car [] cars = new Cars[4];
cars[0] = new Car(3);
cars[1] = new Car(2);
cars[2] = new Car(4);
cars[3] = new Car(6);
Now I want to filter the arr...
Hello
Consider this
void f(vector<const T*>& p)
{
}
int main()
{
vector<T*> nonConstVec;
f(nonConstVec);
}
The following does not compile.The thing is that vector<T*> can not be converted to vector <const T*> , and that seems illogically to me , because there exists implicit conversion from T* to const T*. Why is this ?
v...
Hi all,
I'm working on a code to do a software skinner (bone/skin animation), and I'm at the "optimization" phase (the skinner works pretty well and skin a 4900 triangles mesh with 22 bones in 1.09 ms on a Core Duo 2 Ghz (notebook)). What I need to know is :
1) Can someone show me the way (maybe with pseudocode) to transform a float3 (a...
I want to be able to create vector files like Illustrator does on the iPhone. Does anyone know of an algorithm?
...
Sorry if this has been asked before, but I am wondering what the use of std::vector::front() is.
Is there a reason to use e.g. myvector.front() rather than myvector[0] or myvector.at(0)?
...
I'm making a simple crime sim game.
Throughout it I keep doing the same thing over and over:
// vector<Drug*> drugSack;
for (unsigned int i = 0; i < this->drugSack.size(); i++)
this->sell(drugSack[i]);
Just one example. I hate having all these for loops all over the place omg QQ, anyway to do something like:
drugSack->D...
Is there any collection class in java, that implements push_back() and push_front() methods?
...
I understand the semantics of the 2 operations ,
assign- erases before replacing with supplied values.
insert - inserts values at specified location(allocates new memory if necessary).
Apart from this is there any reason to preffer one over the other?
Or to put it another way, is there any reason to use assign instead of insert.
...
In a programming task, I'm trying to ensure a particular vector contains only unique items. With primitive types, the operation is as simple as:
vector<int> lala;
lala.push_back(1);
lala.push_back(99);
lala.push_back(3);
lala.push_back(99);
sort(lala.begin(), lala.end()); // lala: 1, 3, 99, 99
lala.erase(unique(lala.begin(), lala.end()...
I asked this question about 2 months ago but found none of the answers to be helpful enough. So I am giving it another shot. I think it was my fault not describing it well enough. So lets try again.
Here is a rough idea of what I am trying to accomplish.
The goal is to send a projectile from point T to intercept the object represente...
what is meant by vector in Java is thread safe and synchronized, how is it made thread safe. I'm looking at internal details of implementation
...
Hello, I'm doing this:
private Vector menuOptions;
void addOption(String imagefilename) {
try {
Image i = Image.createImage(imagefilename);
menuOptions.addElement((Object)i);
} catch (Exception e) {
e.printStackTrace();
}
}
And I'm getting:
java.lang.NullPointerException
at GraphicMenu.addOptio...
In C++, is it safe to use an std::map or std::vector concurrently in different threads if you are NOT inserting, just doing .find() operations on it?
...
Consider the class:
MyClass {
int varA;
int varB;
};
I have a vector of pointers to MyClass objects:
std::vector<MyClass*> Vec;
I want to sort the vector according to varA or varB using the same sort function, i.e. :
bool SortFunction(const MyClass* obj1, const MyClass* obj2, const short type) {
if( type == VARA_ID )
...
I made a "Circle" view with this drawRect
- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, color.CGColor);
CGContextAddEllipseInRect(ctx, rect);
CGContextFillPath(ctx);
}
When I try to scale the view up using CGAffineTransformMakeScale(2.0, 2.0), th...
I just started learning about pointers in C++, and I'm not very sure on when to use pointers, and when to use actual objects.
For example, in one of my assignments we have to construct a gPolyline class, where each point is defined by a gVector. Right now my variables for the gPolyline class looks like this:
private:
vector<gVector3*> ...
I know several (all?) STL implementations implement a "small string" optimization where instead of storing the usual 3 pointers for begin, end and capacity a string will store the actual character data in the memory used for the pointers if sizeof(characters) <= sizeof(pointers). I am in a situation where I have lots of small vectors wit...
I'm having an issue where using vector.push_back(value) is overwriting the final value, rather than appending to the end. Why might this happen? I have a sample item in the vector, so it's size never hits zero. Below is the code..
void UpdateTable(vector<MyStruct> *Individuals, MyStruct entry)
{
MyStruct someEntry;
bool isNew...