c++ - Array/Dictionary Objects....
- Michael Comperchio (12/12) Jun 26 2002 I know I'm probably going to be told to find and RTFM...but...I'm trying...
-
Jan Knepper
(5/17)
Jun 26 2002
It's called STL!
- Michael Comperchio (45/71) Jun 26 2002 funny...very funny ;)
- Jan Knepper (18/25) Jun 26 2002 What range are the record numbers?
- Michael Comperchio (30/72) Jun 26 2002 SysListView32...I'll look into that...The last framework I used was from...
- Jan Knepper (3/32) Jun 26 2002 What does not work with vector?
- user domain.invalid (11/95) Jun 26 2002 Not OK since allocated size of vector is zero
- Michael Comperchio (4/116) Jun 26 2002 Much thanks...that push_back is perfect...sorry, this old business
I know I'm probably going to be told to find and RTFM...but...I'm trying to leverage rusty C skills... Anyone have a good dictionary, or array object? or is there some magical Template classes I'm supposed to be learning? If that's true can someone point me to a decent tutorial website? (I'm REAL poor right now, haven't worked in IT in a year and a half..so Barnes and Noble is out of the question) Thanks Michael mcmprch adelphia.net 203 734 5420 203 449 6415
Jun 26 2002
It's called STL! <g> In think there is quite a bit of information on STL on the site. You also could do a search in Google. Jan Michael Comperchio wrote:I know I'm probably going to be told to find and RTFM...but...I'm trying to leverage rusty C skills... Anyone have a good dictionary, or array object? or is there some magical Template classes I'm supposed to be learning? If that's true can someone point me to a decent tutorial website? (I'm REAL poor right now, haven't worked in IT in a year and a half..so Barnes and Noble is out of the question) Thanks Michael mcmprch adelphia.net 203 734 5420 203 449 6415
Jun 26 2002
funny...very funny ;) I think a 'map' is what I have in mind. I want to associate list box indices with record numbers so I can retrieve and display the selected listbox item's associated data record... So I'm trying this: (is it really this simple?...all the complex comp sci verbage in the documentation is daunting for an old business app programmer...) #include <iostream.h> #include <map> struct comparenumbers { bool operator()(const int i1, const int i2) const { return (i1 < i2?1:0); } }; int main() { map<const int, int, comparenumbers> items; items[1] = 31; items[2] = 28; items[3] = 31; items[4] = 30; items[5] = 31; items[6] = 30; items[7] = 31; items[8] = 31; items[9] = 30; items[10] = 31; items[11] = 30; items[12] = 31; cout << "The 6th entry -> " << items[6] << endl; cout << endl << endl; map<const int, int, comparenumbers>::iterator i; i=items.begin(); while( (*i).first ) { cout << "The value is: {"<< (*i++).first << "}" << endl; } return 1; } Thanks for the reply... Michael Jan Knepper wrote:It's called STL! <g> In think there is quite a bit of information on STL on the site. You also could do a search in Google. Jan Michael Comperchio wrote:I know I'm probably going to be told to find and RTFM...but...I'm trying to leverage rusty C skills... Anyone have a good dictionary, or array object? or is there some magical Template classes I'm supposed to be learning? If that's true can someone point me to a decent tutorial website? (I'm REAL poor right now, haven't worked in IT in a year and a half..so Barnes and Noble is out of the question) Thanks Michael mcmprch adelphia.net 203 734 5420 203 449 6415
Jun 26 2002
Michael Comperchio wrote:funny...very funny ;) I think a 'map' is what I have in mind. I want to associate list box indices with record numbers so I can retrieve and display the selected listbox item's associated data record...What range are the record numbers? I think I would use a SysListView32 instead of a ListBox and just associate the ITEM DATA (a DWORD which you can use as pointer!) with the record number. Saves writing extra code. You are taking Windows programming right?So I'm trying this: (is it really this simple?...all the complex comp sci verbage in the documentation is daunting for an old business app programmer...)I would do that with a vector. That since you seems to be using just a linear index... Also, I like to typedef or better wrap the STL... typedef vector < int > IntVector; or class IntVector : protected vector < int > { public : Vector (); // etc... }; Jan
Jun 26 2002
SysListView32...I'll look into that...The last framework I used was from Neuron Data and all their widgets had user data associated with them. VERY convenient for just this purpose. I think though, that since this is a relearning experience for the fun (actually to refresh my programming skills so JUST MAYBE I can get back to doing what I love for a living...) of it I'll hack my way through the STL...I have since last post discovered vector...but this does not seem to work...haven't spent any time yet ... are any of these STL things serializable (right word?)..usable as index files? couldn't get the msoft DB stuff to work so have kinda hacked my own db. vector<int > a; vector<int >::const_iterator i; a[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31; i = a.begin(); // gets the starting point of the vector while (i != a.end()) { // while i is not at the end of the vector cout << "mm" << *i << endl; // prints out each element i++; // increment the iterator } Jan Knepper wrote:Michael Comperchio wrote:funny...very funny ;) I think a 'map' is what I have in mind. I want to associate list box indices with record numbers so I can retrieve and display the selected listbox item's associated data record...What range are the record numbers? I think I would use a SysListView32 instead of a ListBox and just associate the ITEM DATA (a DWORD which you can use as pointer!) with the record number. Saves writing extra code. You are taking Windows programming right?So I'm trying this: (is it really this simple?...all the complex comp sci verbage in the documentation is daunting for an old business app programmer...)I would do that with a vector. That since you seems to be using just a linear index... Also, I like to typedef or better wrap the STL... typedef vector < int > IntVector; or class IntVector : protected vector < int > { public : Vector (); // etc... }; Jan
Jun 26 2002
What does not work with vector? Jan Michael Comperchio wrote:SysListView32...I'll look into that...The last framework I used was from Neuron Data and all their widgets had user data associated with them. VERY convenient for just this purpose. I think though, that since this is a relearning experience for the fun (actually to refresh my programming skills so JUST MAYBE I can get back to doing what I love for a living...) of it I'll hack my way through the STL...I have since last post discovered vector...but this does not seem to work...haven't spent any time yet ... are any of these STL things serializable (right word?)..usable as index files? couldn't get the msoft DB stuff to work so have kinda hacked my own db. vector<int > a; vector<int >::const_iterator i; a[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31; i = a.begin(); // gets the starting point of the vector while (i != a.end()) { // while i is not at the end of the vector cout << "mm" << *i << endl; // prints out each element i++; // increment the iterator }
Jun 26 2002
Michael Comperchio wrote:SysListView32...I'll look into that...The last framework I used was from Neuron Data and all their widgets had user data associated with them. VERY convenient for just this purpose. I think though, that since this is a relearning experience for the fun (actually to refresh my programming skills so JUST MAYBE I can get back to doing what I love for a living...) of it I'll hack my way through the STL...I have since last post discovered vector...but this does not seem to work...haven't spent any time yet ... are any of these STL things serializable (right word?)..usable as index files? couldn't get the msoft DB stuff to work so have kinda hacked my own db. vector<int > a; vector<int >::const_iterator i;OK sofara[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31;Not OK since allocated size of vector is zero Also index starts at 0 not 1. Either do : vector < int > a ( 12 ); or use a.push_back ( 31 ); a.push_back ( 28 ); for assignment. See SGI_STL docs.i = a.begin(); // gets the starting point of the vector while (i != a.end()) { // while i is not at the end of the vector cout << "mm" << *i << endl; // prints out each element i++; // increment the iterator } Jan Knepper wrote:Michael Comperchio wrote:funny...very funny ;) I think a 'map' is what I have in mind. I want to associate list box indices with record numbers so I can retrieve and display the selected listbox item's associated data record...What range are the record numbers? I think I would use a SysListView32 instead of a ListBox and just associate the ITEM DATA (a DWORD which you can use as pointer!) with the record number. Saves writing extra code. You are taking Windows programming right?So I'm trying this: (is it really this simple?...all the complex comp sci verbage in the documentation is daunting for an old business app programmer...)I would do that with a vector. That since you seems to be using just a linear index... Also, I like to typedef or better wrap the STL... typedef vector < int > IntVector; or class IntVector : protected vector < int > { public : Vector (); // etc... }; Jan
Jun 26 2002
Much thanks...that push_back is perfect...sorry, this old business programmer has problems getting started understanding the basic syntax expressions used in the docs... user domain.invalid wrote:Michael Comperchio wrote:SysListView32...I'll look into that...The last framework I used was from Neuron Data and all their widgets had user data associated with them. VERY convenient for just this purpose. I think though, that since this is a relearning experience for the fun (actually to refresh my programming skills so JUST MAYBE I can get back to doing what I love for a living...) of it I'll hack my way through the STL...I have since last post discovered vector...but this does not seem to work...haven't spent any time yet ... are any of these STL things serializable (right word?)..usable as index files? couldn't get the msoft DB stuff to work so have kinda hacked my own db. vector<int > a; vector<int >::const_iterator i;OK sofara[1] = 31; a[2] = 28; a[3] = 31; a[4] = 30; a[5] = 31; a[6] = 30; a[7] = 31; a[8] = 31; a[9] = 30; a[10] = 31; a[11] = 30; a[12] = 31;Not OK since allocated size of vector is zero Also index starts at 0 not 1. Either do : vector < int > a ( 12 ); or use a.push_back ( 31 ); a.push_back ( 28 ); for assignment. See SGI_STL docs.i = a.begin(); // gets the starting point of the vector while (i != a.end()) { // while i is not at the end of the vector cout << "mm" << *i << endl; // prints out each element i++; // increment the iterator } Jan Knepper wrote:Michael Comperchio wrote:funny...very funny ;) I think a 'map' is what I have in mind. I want to associate list box indices with record numbers so I can retrieve and display the selected listbox item's associated data record...What range are the record numbers? I think I would use a SysListView32 instead of a ListBox and just associate the ITEM DATA (a DWORD which you can use as pointer!) with the record number. Saves writing extra code. You are taking Windows programming right?So I'm trying this: (is it really this simple?...all the complex comp sci verbage in the documentation is daunting for an old business app programmer...)I would do that with a vector. That since you seems to be using just a linear index... Also, I like to typedef or better wrap the STL... typedef vector < int > IntVector; or class IntVector : protected vector < int > { public : Vector (); // etc... }; Jan
Jun 26 2002