Advertisement
phi2dao

Table<K, V>

Sep 29th, 2024 (edited)
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public class Table<K, V> where K : notnull;
  2.  
  3. private IEnumerable<LinkedListNode<V>> GetNodes(K key)
  4. {
  5. if (!_records.TryGetKey(key, out var record))
  6. yield break;
  7. LinkedListNode<V> node = record.Head;
  8. for (int i = 0; i < record.Count; i++)
  9. {
  10. yield return node.Value;
  11. node = node.Next!;
  12. }
  13. }
  14.  
  15. private readonly Dictionary<K, Record> _records = [];
  16. private readonly LinkedList<V> _values = [];
  17.  
  18. private readonly record struct Record(LinkedListNode<V> Head, int Count);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement