* Instantiating a generic ADT from another ADT @ 2001-04-23 0:14 Alex Angas 2001-04-23 2:46 ` Jeffrey Carter 0 siblings, 1 reply; 8+ messages in thread From: Alex Angas @ 2001-04-23 0:14 UTC (permalink / raw) Hey all, I'm having a great deal of trouble trying to instantiate a generic list package ADT (with generic functions) from another ADT (a hash table ADT). Can this even be done? I'm trying to create a linked list of hash tables. The problem is that I am declaring functions that use the as-yet undeclared type of hash_table_list. The compiler isn't happy about just saying that it's private so I tried to declare it at the end of the private section. Didn't work! Compiler also isn't very happy about declaring that function to be used by generic_list_package in the private section of hash_table.ads. I really don't know how to do this. Here's the code: *** hash_table.ads: with generic_list_package; package hash_table is type hash_table_list is private; function lookup(i : integer) return hash_table_list; ... private ... function get_key(i: in hash_table_entry) return integer; -- this is a generic function in generic_list_package package hash_table_list_package is new generic_list_package( item_type => hash_table_entry, key_type => integer); type hash_table_list is new hash_table_list_package.item_list; end hash_table; *** generic_list_package.ads: generic type item_type is private; -- type stored in list type key_type is private; -- type for comparing items in list with function get_key(item: in item_type) return key_type is <>; -- used for comparing keys package generic_list_package is type item_ptr is private; type item_list is limited private; .,. end generic_list_package; *** Any ideas?? Cheers, Alex. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 0:14 Instantiating a generic ADT from another ADT Alex Angas @ 2001-04-23 2:46 ` Jeffrey Carter 2001-04-23 3:03 ` Alex Angas 0 siblings, 1 reply; 8+ messages in thread From: Jeffrey Carter @ 2001-04-23 2:46 UTC (permalink / raw) Without knowing the definition of Hash_Table_Entry I can't be sure this is the only problem, but Hash_Table.Hash_Table_List is private, while Hash_Table.Hash_Table_List_Package.Item_List is limited private, so the full definition of Hash_Table_List cannot be "new Hash_Table_List_Package.Item_List". -- Jeff Carter "We call your door-opening request a silly thing." Monty Python & the Holy Grail ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 2:46 ` Jeffrey Carter @ 2001-04-23 3:03 ` Alex Angas 2001-04-23 22:29 ` Des Walker 0 siblings, 1 reply; 8+ messages in thread From: Alex Angas @ 2001-04-23 3:03 UTC (permalink / raw) Ah sorry, yeah Hash_Table.Hash_Table_List is private. Any suggestions as to how best to implement this? I don't mind if I have to change the whole thing!! Alex. "Jeffrey Carter" <jrcarter@acm.org> wrote in message news:3AE39790.6E337130@acm.org... > Without knowing the definition of Hash_Table_Entry I can't be sure this > is the only problem, but Hash_Table.Hash_Table_List is private, while > Hash_Table.Hash_Table_List_Package.Item_List is limited private, so the > full definition of Hash_Table_List cannot be "new > Hash_Table_List_Package.Item_List". > > -- > Jeff Carter > "We call your door-opening request a silly thing." > Monty Python & the Holy Grail ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 3:03 ` Alex Angas @ 2001-04-23 22:29 ` Des Walker 2001-04-23 23:48 ` Marc A. Criley 2001-04-27 19:22 ` Simon Wright 0 siblings, 2 replies; 8+ messages in thread From: Des Walker @ 2001-04-23 22:29 UTC (permalink / raw) Alex Angas <wgd@adelaide.on.net> wrote in message news:3ae39c1c@duster.adelaide.on.net... > Ah sorry, yeah Hash_Table.Hash_Table_List is private. > > Any suggestions as to how best to implement this? I don't mind if I have to > change the whole thing!! > > Alex. > > "Jeffrey Carter" <jrcarter@acm.org> wrote in message > news:3AE39790.6E337130@acm.org... > > Without knowing the definition of Hash_Table_Entry I can't be sure this > > is the only problem, but Hash_Table.Hash_Table_List is private, while > > Hash_Table.Hash_Table_List_Package.Item_List is limited private, so the > > full definition of Hash_Table_List cannot be "new > > Hash_Table_List_Package.Item_List". > > > > -- > > Jeff Carter > > "We call your door-opening request a silly thing." > > Monty Python & the Holy Grail > > Hi, This isn't an answer to your question about ADTs, but in consideration of your statement that you don't mind changing the whole thing. If this doesn't interest you then apologies for taking this thread off topic. If you're looking for code to handle generic lists have you tried using the Booch Components. The BCs were initially developed for C++, but there are ports to Ada, and Eiffel and I think I've seen a Java port. As well as support for lists, the BCs also provide provide support for "Bags, Collections, Deques, Graphs, ... , Maps, Queues, Rings, Sets, Stacks, and Trees". The Booch Components have been around for a numer of years now, although I haven't used them to a great extent yet. I did try out the AVL Tree - I found the performance when managing a million items was on a par with a well vetted C version of the AVL tree I obtained of the net. The Ada port isn't as complete as the C++ version, but is still being maintained. You can download a copy of the Booch Components from http://www.pogner.demon.co.uk/components/bc/index.html The download comes with a set of test programs which give guidance on how to use the component packages. HTH Des Walker ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 22:29 ` Des Walker @ 2001-04-23 23:48 ` Marc A. Criley 2001-04-24 5:26 ` Alex Angas 2001-04-24 6:31 ` Des Walker 2001-04-27 19:22 ` Simon Wright 1 sibling, 2 replies; 8+ messages in thread From: Marc A. Criley @ 2001-04-23 23:48 UTC (permalink / raw) Des Walker wrote: > > If you're looking for code to handle generic lists have you tried using > the Booch Components. The BCs were initially developed for C++, but > there are ports to Ada, and Eiffel and I think I've seen a Java port. As > well as support for lists, the BCs also provide provide support for > "Bags, Collections, Deques, Graphs, ... , Maps, Queues, Rings, Sets, > Stacks, and Trees". > > The Booch Components have been around for a numer of years now, although > I haven't used them to a great extent yet. I did try out the AVL Tree - > I found the performance when managing a million items was on a par with > a well vetted C version of the AVL tree I obtained of the net. The Ada > port isn't as complete as the C++ version, but is still being > maintained. > > You can download a copy of the Booch Components from > http://www.pogner.demon.co.uk/components/bc/index.html [Massive, loud, throat-clearing noises...] The Booch Components were originally written in Ada 83 around the mid-80s (I first encountered them in '87). Grady went and rewrote them later in C++, significantly optimizing their implementation based on what he learned the first time around. This latter rewrite is the base for the Ada, et.al. ports mentioned above. Marc A. Criley Senior Staff Engineer Quadrus Corporation www.quadruscorp.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 23:48 ` Marc A. Criley @ 2001-04-24 5:26 ` Alex Angas 2001-04-24 6:31 ` Des Walker 1 sibling, 0 replies; 8+ messages in thread From: Alex Angas @ 2001-04-24 5:26 UTC (permalink / raw) Cool, thanks! "Marc A. Criley" <mcqada@earthlink.net> wrote in message news:3AE4B1F7.997F8D95@earthlink.net... > Des Walker wrote: > > > > > If you're looking for code to handle generic lists have you tried using > > the Booch Components. The BCs were initially developed for C++, but > > there are ports to Ada, and Eiffel and I think I've seen a Java port. As > > well as support for lists, the BCs also provide provide support for > > "Bags, Collections, Deques, Graphs, ... , Maps, Queues, Rings, Sets, > > Stacks, and Trees". > > > > The Booch Components have been around for a numer of years now, although > > I haven't used them to a great extent yet. I did try out the AVL Tree - > > I found the performance when managing a million items was on a par with > > a well vetted C version of the AVL tree I obtained of the net. The Ada > > port isn't as complete as the C++ version, but is still being > > maintained. > > > > You can download a copy of the Booch Components from > > http://www.pogner.demon.co.uk/components/bc/index.html > > [Massive, loud, throat-clearing noises...] > > The Booch Components were originally written in Ada 83 around the > mid-80s (I first encountered them in '87). Grady went and rewrote them > later in C++, significantly optimizing their implementation based on > what he learned the first time around. This latter rewrite is the base > for the Ada, et.al. ports mentioned above. > > Marc A. Criley > Senior Staff Engineer > Quadrus Corporation > www.quadruscorp.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 23:48 ` Marc A. Criley 2001-04-24 5:26 ` Alex Angas @ 2001-04-24 6:31 ` Des Walker 1 sibling, 0 replies; 8+ messages in thread From: Des Walker @ 2001-04-24 6:31 UTC (permalink / raw) Marc A. Criley <mcqada@earthlink.net> wrote in message news:3AE4B1F7.997F8D95@earthlink.net... > [Massive, loud, throat-clearing noises...] > > The Booch Components were originally written in Ada 83 around the > mid-80s (I first encountered them in '87). Grady went and rewrote them > later in C++, significantly optimizing their implementation based on > what he learned the first time around. This latter rewrite is the base > for the Ada, et.al. ports mentioned above. > > Marc A. Criley > Senior Staff Engineer > Quadrus Corporation > www.quadruscorp.com Whoops! thanks for the correction. I misinterpreted a description I read, about the Ada set of BC since it said the Ada version had the same key abstractions as the C++ version. But I see now this just meant the Ada95 version is later than the C++ version with lessons learnt. Des Walker ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Instantiating a generic ADT from another ADT 2001-04-23 22:29 ` Des Walker 2001-04-23 23:48 ` Marc A. Criley @ 2001-04-27 19:22 ` Simon Wright 1 sibling, 0 replies; 8+ messages in thread From: Simon Wright @ 2001-04-27 19:22 UTC (permalink / raw) "Des Walker" <des.walker@dessy.fsnet.co.uk> writes: > If you're looking for code to handle generic lists have you tried using > the Booch Components. The next release of the BCs will say <dt>Lists; to use or not to use?</dt> <dd> Many people, faced with the BCs for the first time, choose Lists (Single or Double) as their standard Container. <p>This is probably <em>not</em> the best choice. Lists are complex entities which, I suppose, would be useful if you were implementing a list-processing engine like Lisp. <p><font color="red">You'll be a lot better off using Collections!</font> <p> </dd> (pardon the HTML :) ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-04-27 19:22 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-04-23 0:14 Instantiating a generic ADT from another ADT Alex Angas 2001-04-23 2:46 ` Jeffrey Carter 2001-04-23 3:03 ` Alex Angas 2001-04-23 22:29 ` Des Walker 2001-04-23 23:48 ` Marc A. Criley 2001-04-24 5:26 ` Alex Angas 2001-04-24 6:31 ` Des Walker 2001-04-27 19:22 ` Simon Wright
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox