• Create Account

#ActualCuajin

Posted 06 April 2012 - 01:27 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.

// Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.

myList.exchange(2, 5); // giving it position numbers to exchange.
}


The big problem is I can't get it to switch the Node's position on the list without destroying Nodes (I lose the reference to pointers when I switch). Clearly Nodes and me don't like each other

From the TestClass I want to say exchange what's on position 2 with what is on position 5.

#5Cuajin

Posted 06 April 2012 - 01:26 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.

// Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.

myList.exchange(2, 5); // giving it position numbers to exchange.
}


The big problem is I can't get it to switch the Node's position on the list without destroying Nodes (I lose the reference to pointers when I switch). Clearly Nodes and me don't like each other

#4Cuajin

Posted 06 April 2012 - 01:25 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.
/
/ Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.

myList.exchange(2, 5); // giving it position numbers to exchange.
}


The big problem is I can't get it to switch the Node's position on the list without destroying Nodes (I lose the reference to pointers when I switch). Clearly Nodes and me don't like each other

#3Cuajin

Posted 06 April 2012 - 01:24 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.
// Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.
myList.exchange(2, 5); // giving it position numbers to exchange.
}


The big problem is I can't get it to switch the Node's position on the list without destroying Nodes (I lose the reference to pointers when I switch). Clearly Nodes and me don't like each other

#2Cuajin

Posted 06 April 2012 - 01:23 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
	class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.
// Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.
myList.exchange(2, 5); // giving it position numbers to exchange.
}


The big problem is I can't get it to switch the Node's position on the list without destroying Nodes (I lose the reference to pointers when I switch). Clearly Nodes and me don't like each other

#1Cuajin

Posted 06 April 2012 - 01:21 PM

I’m trying to exchange the position of two nodes a and b.

I have the Node class that helps me create a list.
    class Node
{
E info;
Node next;

Node (E x)
{
next = null;
info = x;
}
}


Then I have class List.
public class List<E>
{
// some methods like addToList(). They work.
// Problem here!
public void exchangeNodes(int a, int b)
{

{
// here I wrote a bunch of noob code that if you looked at it your eyes would hurt.
}
}


TestClass
public class TestClass
{
List myList = new List();
// populating the list with strings.