www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Array/Dictionary Objects....

↑ ↓ ← Michael Comperchio <mcmprch adelphia.net> writes:
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
↑ ↓ Jan Knepper <jan smartsoft.cc> writes:
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 <mcmprch adelphia.net> writes:
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
↑ ↓ Jan Knepper <jan smartsoft.cc> writes:
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
↑ ↓ Michael Comperchio <mcmprch adelphia.net> writes:
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
→ Jan Knepper <jan smartsoft.cc> writes:
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
user domain.invalid writes:
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 sofar
   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;

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
↑ ↓ → Michael Comperchio <mcmprch adelphia.net> writes:
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 sofar
   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;

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