class GenLinkedListDemo { static void Main() {
// .
LinkedList<char> 11 = new LinkedList<char>();
Console.WriteLine(" : " + 11.Count) Console.WriteLine ();
Console.WriteLine(" 5 ");
// .
11.AddFirst('');
11.AddFirst('');
11.AddFirst('');
11.AddFirst(' D');
11.AddFirst(' *);
Console.WriteLine(" : " + 11.Count);
// , .
LinkedListNode<char> node;
Console.Write(" : "); for(node = 11.First; node!= null; node = node.Next)
Console.Write(node.Value + " ");
Console.WriteLine("\n");
// , foreach.
Console.Write(" foreach: "); foreach(char ch in 11)
Console.Write(ch + " ");
Console.WriteLine("\n");
// , . Console.Write(" : "); for(node = 11.Last; node!= null; node = node.Previous)
Console.Write(node.Value + " ");
Console.WriteLine ("\n");
// .
Console.WriteLine(" 2 ");
// .
11.Remove(11);
11.Remove('');
Console.WriteLine(" : " + 11.Count);
// foreach.
Console.Write(" : "); foreach(char ch in 11)
Console.Write(ch + " ");
Console.WriteLine ("\n");
// .
11.AddLast('X');
11.AddLast('Y');
11.AddLast('Z');
Console.Write(" : "); foreach(char ch in 11)
Console.Write(ch + " ");
Console.WriteLine("\n");
}
}
.
. :
5 : 5
: D
foreach: D
: D
2 : 3
: D
: D X Y Z
, , Next Previous. , , .
DictionaryCTKey, TValue>
|
|
Dictionary<TKey, TValue> "-" . . Hashtable. Dictionary<TKey, TValue> IDictionary, IDictionary<TKey, TValue>, ICollection, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable, IEnumerable<KeyValuePair<TKey, TValue>>, ISerializable IDeserializationCallback. . , .
Dictionary<TKey, TValue> . .
Public Dictionary()
public Dictionary(IDictionaryCTKey, TValue> dictionary) public Dictionary(int capacity)
. dictionary. capaci ty , . , , , , , , .
Dictionary<TKey, TValue> . . 25.17.
25.17. , Die tionaryCTKey, TValue>
Public
value)
void Add(TKey key, TValue
-", key value. key , , ArgumentException
Public
key)
Bool
ContainsKey(TKey
true, key ; false
Public
value)
Bool
ContainsValue(TValue
true, value; false
Public
Bool
Remove(TKey key)
key . true, key false
, Dictionary<TKey, TValue> , , , . .
public IEqualityComparer<TKey> Comparer { get; } public Dictionary<TKey, TValue>. KeyCollection Keys { get; } public Dictionary<TKey, TValue>. ValueCollection Values { get; }
-
, , , Keys Values. DictionaryCTKey, TValue>.KeyCollection Dictionary<TKey, TValue>. ValueCollection , ICollection IEnumerable.
|
|
, DictionaryCTKey, TValue> , IDictionary<TKey, TValueX
public TValue this[TKey key] { get; set; }
, . , .
DictionaryCTKey, TValue> "-7' KeyValuePairCTKey, TValueX , .