c# - Sorting generic linked list -
i have in generic linked list done except sorting. , don't know how use icomparable or how go doing because it's generic. don't know comparing or sorting?
public class node<t> : icomparable<t> { private node<t> next; private t item; } so
public int compareto( t other ) { // todo: find out how throw new notimplementedexception(); } it against instructions convert array , sort it, convert back.
having linked list node object implement icomparable makes absolutely no sense exact reasons describe. instead, classes use in linked list should implement it. in fact, can require generic type constraint:
myclass<t> t : icomparable<t> {} with done, can use t if were icomparable when performing sort.
Comments
Post a Comment