0

Please i need help Class linkedListEnumerator : IEnumerator

Im making HashTable with a dictionary class that Implements IDictionary, Im using a linked list of KeyValuePairs where I have to create an enumerator class to enumerate the hashtable, but I dont know how to implement my enumerator class. It is so far named LinkedListEnumerator : Ienumerator<KeyValuePair<TKey, TValue>> but Im not sure how to do the constructor nor the movenext methos or what fields I need Im creating and implementing the new dictionary class, so not just using the Dictionary ThehashTable = new Dictionary Im trying to use chaining, so the first linked list is not dynamic but the ones holding the KeyValuePairs are I dont understand what type current should be in the enumerator class and what the constructor should take in

10th Mar 2022, 4:08 AM
Chioma Chieke
5 Respuestas
+ 1
public class HashDictionary<TKey, TValue> : IDictionary<TKey, TValue> KeyValuePair<TKey, TValue>? First { get; protected set; } LinkedList<KeyValuePair<TKey, TValue>>[]? HashList; HashDictionary() { HashList = new LinkedList<KeyValuePair<TKey, TValue>>[20];
10th Mar 2022, 12:17 PM
Chioma Chieke
0
Chioma Chieke Can you share the code once
10th Mar 2022, 10:16 AM
B.VIDYADHAR VIJJU
B.VIDYADHAR VIJJU - avatar
0
I will check and let you know
10th Mar 2022, 10:17 AM
B.VIDYADHAR VIJJU
B.VIDYADHAR VIJJU - avatar
0
LinkedListEnumerator : IEnumerator<KeyValuePair<TKey, TValue>> { KeyvaluePair<TKey, TValue> current; //KeyValuePair<TKey, TValue> First; LinkedListNode<keyValuePair<TKey, TValue>>? Node; O references public object? Current => current; O references KeyvaluePair<TKey, TValue> IEnumerator<KeyValuePair<TKey, TValue>>.Current => current; 1 reference public LinkedListEnumerator(LinkedList<KeyValuePair<TKey, TValue>>[]? list) { Node = current = First; O references public bool MoveNext() { current = current. Next; return current != null; O eferences public void Reset() { current = First; O references public void Dispose() {
10th Mar 2022, 12:17 PM
Chioma Chieke
0
I created my own dictionary class that implements the IDictionary interface which I then Implement everything that IDictionary implements, but I need to create my own enumerator class for that to work, so it can enumerate through the hashlist
10th Mar 2022, 12:18 PM
Chioma Chieke