fusionplus
March 22nd, 2007, 09:03 PM
Hi.. i have a complicated doublylinkedlist that i am stuck at a position.. See, the list is distributed into boxes... each box is of certain size.. once the elements added to first box are filled, it creates the next box... for e.g.
A-b-c-d-E-f-g-h-i-J-k-l-m
The capital letters are box headers. Each box is of size 4.
the value variable tells which node.
Now, if i want to get to E box header, how can i do it.. i am using a while loop,
but the loop doesn't stop at the boxheader that has the element, it goes to the end boxheader.. here's the code...
(i have to get the value number on the linked list. First by getting to that box and then getting to that value node).
/** nextBox goes from one boxheader to next. */
BNode node = front;
BNode node2 = null;
int i = 0;
while (i < index) {
node = node.nextBox;
node2 = node;
}
for (int x = i; x < index; x++) {
node2 = node2.next;
}
System.out.println(node2.getValue());
Now suppose if the value was 5. The node2 should return "f". but instead the nextBox goes all the way to the end... PLZ help..
A-b-c-d-E-f-g-h-i-J-k-l-m
The capital letters are box headers. Each box is of size 4.
the value variable tells which node.
Now, if i want to get to E box header, how can i do it.. i am using a while loop,
but the loop doesn't stop at the boxheader that has the element, it goes to the end boxheader.. here's the code...
(i have to get the value number on the linked list. First by getting to that box and then getting to that value node).
/** nextBox goes from one boxheader to next. */
BNode node = front;
BNode node2 = null;
int i = 0;
while (i < index) {
node = node.nextBox;
node2 = node;
}
for (int x = i; x < index; x++) {
node2 = node2.next;
}
System.out.println(node2.getValue());
Now suppose if the value was 5. The node2 should return "f". but instead the nextBox goes all the way to the end... PLZ help..