I have to insert State objects into the link list, but the linklist is sorted I placed my notes in my code. Any help would be appreciated.
public void insertAddStack()
{
int probe=0, index=0;
States key=null;
for (;
index < addStackItems;
index++) //loops through keys
{
for (;
probe < numStates;
probe++)
{
if (myStates[index].getStateName().equals
(addStack.pop().getStateName())) //compares stateNames
break; //ends inner for loop
}
}//end inner for loop
if (probe == numStates)
// returns can not find key when probes equal number of states
{
myList.insertAfter(key, addStack.pop());<---the Key here should be set to a
State object to add the popped object after
I cannot figure out how I would get that. I'm
not asking for code, but just to be pointed in
the right direction here. I know I need two
pointers it needs to do a search(binary maybe?)
and then possibly use the comparable startswith
method, but I know I can't use startswith "A"
or something it has to compare and place this
object in the right order(a few states start
with "A")
}//end if
else //returns found key with linear probe count
{
System.out.println("Dupe Add Attempted"
+ "\nFound " + addStack.pop().getStateName());
}//end else