Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List

Status
Not open for further replies.

jvff

Programmer
Apr 1, 2001
64
BR
Hello,
is there a way to use some sort of list as an array? I want to, example:

list<int> myList;

myList[3] = 4;
int a = myList[3];
mylist[30000243857292084] = 56937;
a = mylist[30000243857292084];
myList[0] = 0;
int b = myList[0];
...

Is there any way to do something similiar? ThanX in advance,

JVFF
 
// this will work
vector<int> myList(10);

myList[3] = 4;
int a = myList[3];
// but not this, it is just silly
//mylist[30000243857292084] = 56937;
//a = mylist[30000243857292084];

// again this is OK
myList[0] = 0;
int b = myList[0];


-pete
[sub]I just can't seem to get back my IntelliSense[/sub]
 
unless he wants to implement some sort of sparse array or something... I don't know STL at all, maybe there's something there.

A map template might do the trick as well.
 
hi U can use STl

std::vector<int> x;
int a=10;
x.push_back(a);
a = x[0];
int b = 20;
x.push_back(b);
b=x[1];
...
....



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top