|
Post by CooLiBoP on Feb 18, 2002 17:38:54 GMT -5
Ok i'm re-writing my A1 URLList code the same way that it is sugeested on the 148 page (with a URLPair class etc.). I was just wondering how they performed the swap command...Does their add method in URLList take an index? How did they add to a specific index? Currently my add method just creates a new URLPair object and puts it at the end of the list...is there something I'm missing here?
|
|
|
Post by 1.8T on Feb 18, 2002 23:18:39 GMT -5
i used setElementAt()
|
|
|
Post by CooLiBoP on Feb 19, 2002 0:09:44 GMT -5
erm...I know that I can use add(index i, object b) (for an arraylist) but I was wondering about the add method in the URLList class...according to their solution they only have 1 add method which I assume adds the object to the end of the list? So without making a new addToIndex method say, how would I do this?
|
|
|
Post by 1.8T on Feb 19, 2002 22:28:09 GMT -5
oh ic wut u mean,., i haven't started yet., but i think u iterate until the specified index, then add then add the rest.., ., really haven't started so not sure.,., IM me if that works. kekeke
|
|
|
Post by Brutal_Chicken on Feb 20, 2002 14:36:48 GMT -5
erm...I know that I can use add(index i, object b) (for an arraylist) but I was wondering about the add method in the URLList class...according to their solution they only have 1 add method which I assume adds the object to the end of the list? So without making a new addToIndex method say, how would I do this? The way they described it in their solution is that they used a lot of add and remove calls. I'm with you, I'm making an add method that just adds to a specific index. I mean, what if you have a large list of urls/titles? You'd have to iterate through all of them up to the ith and jth ones just to do what ArrayList and Vector already can do.
|
|
|
Post by Bahamut on Feb 20, 2002 19:27:52 GMT -5
I'm sorry, but this has to be said: 1.8T, your icon is adorable!
|
|
|
Post by Brutal_Chicken on Feb 20, 2002 23:04:45 GMT -5
Ok, so I wrote a remove method and a replace method for URLList bringing the total to 5 methods. I really don't wanna write a method that'll keep calling add() and remove() to swap two items. It's inefficient ain't it? And, yes, that is so cute. What the hell is it?
|
|
|
Post by 1.8T on Feb 21, 2002 1:39:12 GMT -5
Mashi Maro, some korean cartoon u can watch the .swf here www.plusq.com/mashimaro.html ;D ;D anyways. back to the assignment hahaha, i'm having trouble doing the linkedlist methods for adding to an index, im not sure as to how the user inputs the index , is it through a parameter in my method?., and if so , how do i go about going through the linked list to the specified index when there isn't index values for the linked list?
|
|
|
Post by Brutal_Chicken on Feb 21, 2002 10:51:04 GMT -5
You just have to use a for loop with an int index = 0 as your starting point. Just start with head.getLink() as your initial value before the for loop and you're in business. And yes, it needs to be a parameter.
|
|
|
Post by Brutal_Chicken on Feb 25, 2002 17:26:50 GMT -5
Did anyone actually do the swap method the way they did? As in remove the two URLPairs at indices x and y then reshuffle the entire list from x or y (whichever was the least) swapping the two URLPairs apart in the process. I just wrote a replace method and I'm wondering if I'm gonna get marks off... Probably will.
|
|
|
Post by CooLiBoP on Feb 25, 2002 21:14:49 GMT -5
Did anyone actually do the swap method the way they did? I did after a bit of tweaking around with my URLList class...
|
|