public
class
node
public
node
(object element)
}
public
class
testlinkedlist
node temp=null;
if(index<
(size>>1)
)}else
}return temp.element;
}public
void
add(object obj)
else
size++;}
@override
public string tostring()
sb.setcharat
(sb.
length()
-1,']');
return sb.
tostring()
;}public
static
void
main
(string[
] args)
}
public
class
testlinkedlist02
if(down!=null)
//被刪除的元素是第乙個元素時
if(index==0)
//被刪除的元素最後乙個元素時
if(index==size-1)
size--;}
}public node getnode
(int index)
}else
}return temp;}//
//["a","b","c","d","e","f"] 2
public object get
(int index)
node temp=
getnode
(index)
;return temp!=null?temp.element:null;
}public
void
add(object obj)
else
size++;}
@override
public string tostring()
sb.setcharat
(sb.
length()
-1,']');
return sb.
tostring()
;}public
static
void
main
(string[
] args)
}
public
class
testlinkedlist03
}public
void
remove
(int index)
if(down!=null)
//被刪除的元素是第乙個元素時
if(index==0)
//被刪除的元素最後乙個元素時
if(index==size-1)
size--;}
}public node getnode
(int index)
}else
}return temp;}//
//["a","b","c","d","e","f"] 2
public object get
(int index)
node temp=
getnode
(index)
;return temp!=null?temp.element:null;
}public
void
add(object obj)
else
size++;}
@override
public string tostring()
sb.setcharat
(sb.
length()
-1,']');
return sb.
tostring()
;}public
static
void
main
(string[
] args)
}
public
class
testlinkedlist04
}public
void
remove
(int index)
if(down!=null)
//被刪除的元素是第乙個元素時
if(index==0)
//被刪除的元素最後乙個元素時
if(index==size-1)
size--;}
}private node getnode
(int index)
}else
}return temp;}//
//["a","b","c","d","e","f"] 2
public e get
(int index)
private
void
checkrange
(int index)
}public
void
add(e element)
else
size++;}
@override
public string tostring()
sb.setcharat
(sb.
length()
-1,']');
return sb.
tostring()
;}public
static
void
main
(string[
] args)
}
LinkedList集合整理
jdk1.6以後的新特性 addfirst offerfirst addlast offerlast getfirst peekfirst getlast peeklast removefirst pollfirst removelast polllast jdk1.6以後,刪除或獲取元素時,如果列...
泛型集合 LinkedList
using system using system.collections.generic using system.linq using system.text using system.collections namespace linkedlist class program static v...
集合 list 迭代 linkedList
集合類 定義 用於儲存物件最常用的一種方式 集合類與陣列的比較 陣列和集合類同是容器,陣列雖然也可以儲存物件,但是長度固定,而集合類為可變長度,陣列可儲存基本資料型別,集合只存放物件,而且可以存放不同型別的物件。集合框架中的常用介面 collection 介面有兩個子介面 list 列表 set 集...