|
-
November 15th, 2009, 05:58 AM
#1
[RESOLVED] generic class
Hello.
I want to make a generic list class for, let's say, storing a graph. For each node (raging from 1 to n) I keep a linked list for it's neighbors. But I don't want to make an array of lists. I want to use the generic class for making a linked list of linked lists. Roughly speaking, I want to obtain something like this: myList< myList<Integer> > Graph. How can I do it?
I will post a part of the code, to be more precise:
Code:
class Node<T>{
T key;
Node<T> prev, next;
Node(T val) {
key = val;
}
}
class List<T extends Comparable<T>> {
Node<T> First, Last;
void insert(T val) { ... }
void write() { ... }
}
class myMain {
public static void main(String arg[]) {
List< something > Graph = new List< something >();
....
} }
Thank you for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|