|
|||||||
| Programming, Coding, (Web)Design Discuss all your programming or design needs with likeminded people. |
![]() |
|
|
Thread Tools |
|
|
#1 |
|
Brazilian Fool
Join Date: May 2002
Location: São Paulo
Posts: 3,380
Rep Power: 0 ![]() |
java and ADTs
hi anyone good with abstract data types in java?
we're given a list ADT and have to use it to create and implement a Queue and Stack ADTs... i've already defined them but am not sure how to go about using and modifying the lists' methods... say, the isEmpty() method is fine and i want to use it as is, but the clear() method i'd like to modify somewhat, how do i do that without changing the actual method in the original list ADT? thx!
__________________
The Aliens mostly come out at night... mostly... |
|
|
|
|
|
#2 |
|
BSD SMASH!
Join Date: May 2002
Location: A rabbit hole. . .
Posts: 1,170
Rep Power: 0 ![]() |
I had a similar problem, except it was in C++. I don't think you actually edit the list class. All you do is just access the beginning/end of the list in order to emulate the stack and queue. For a stack, I would insert and remove from the end, while a queue I would just insert from the end and remvoe from the beginning.
Anyway, if you wanted to edit the clear(), you probably need some sort of extended class which will allow for you to defien a new clear function.
__________________
quad (FreeBSD/amd64 8-CURRENT): Intel Q6600 - Asus P5E-VM HDMI - 2x2 GB Kingston PC6400 DDR2 Ram - Seagate 320GB 7200RPM HD - 2xSeagate 1TB 7200RPM HD in RAID 1 via ZFS - Lite-On 20x DVD Multi Recorder - Coolermaster Centurion 5 router (FreeBSD/amd64 8-CURRENT): Intel E4500 - Intel D945GCNL - 2 GB PC6400 Mushkin Ram - Lite-On 48x24x48x16 - Seagate 320GB 7200RPM HD - Silverstone SST-SG02-F wanderer (FreeBSD/i386 7-CURRENT): Lenovo Thinkpad T61p mini (OS X 10.5): Intel Core 2 Duo @ 1.8Ghz, 4 GB Mushkin PC5400 Ram - Headroom MicroDAC Portable sound: Rockboxed iPod Video -> Westone UM2's Not-So-Portable Sound: Headroon MicroDAC -> Singlepower PPX3-SLAM -> Grado RS-1's or Beyerdynamic DT-880's Very-Not-Portable-Sound: Squeezebox v3 -> Denon AVR-1507 -> B&W 683's & Sunfire HRS-10 |
|
|
|
|
|
#3 | |
|
A Legend in Underwear
Join Date: May 2002
Location: Unknown
Posts: 5,255
Rep Power: 70 ![]() |
Re: java and ADTs
Quote:
When you replace a method in an ADT you have to recode it entirely. Fortunately, there's plently of good examples on the 'net for Java for most of the popular ADT methods regarding common objects - like collection based classes. C# on the other hand - which I'm learning atm - has little good examples on the 'net. Took me about 3 days to find a fast custom strong typed collection class which supported the functionality I require. Now everthing is peachy
__________________
Gentoo Linux - Developer (baselayout) Read my blog "I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." Stephen Roberts |
|
|
|
|
|
|
|
|
Brazilian Fool
Join Date: May 2002
Location: São Paulo
Posts: 3,380
Rep Power: 0 ![]() |
sorry that was from a while ago, i figured it all out already!
but good to know some people here are competent with java for future referene
__________________
The Aliens mostly come out at night... mostly... |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|