child pages:
page index:
links:
// code from https://stackoverflow.com/questions/29205934/c-sharp-equivalent-of-linkedhashmap // java linked hashmap https://www.geeksforgeeks.org/linkedhashmap-class-in-java/
// c# iterators https://www.geeksforgeeks.org/iterators-in-c-sharp/
// expose an iterator google search https://www.google.com/search?q=c%23+what+does+expose+an+iterator+mean&rlz=1C1GCEA_enUS940US940&oq=c%23+what+does+expose+an+iterator+mean&aqs=chrome..69i57j69i58.11563j0j3&sourceid=chrome&ie=UTF-8
namespace linkedhashmaptest lhm["apple"] = "theapplestring"; lhm.DoIteration();
Console.WriteLine(lhm["apple"]); Console.WriteLine(lhm.PopFirst());
class LinkedHashMap<T, U> public void DoIteration() public U this[T c] set D[c] = new LinkedListNode<Tuple<U, T>>(Tuple.Create(value, c)); public bool ContainsKey(T k) public U PopFirst() public int Count using System;
using System.Collections.Generic;
// another https://stackoverflow.com/questions/486948/linkedhashmap-in-net
{
internal class linkedhashmaptest
{
static void Main(string[] args)
{
var lhm = new LinkedHashMap<string, string>();
lhm["bstuff"] = "bstring";
lhm["anotheraentry"] = "secondastring";
Console.WriteLine(lhm["bstuff"]);
//Console.WriteLine(lhm["cnotthere"]); // throws not there exception
Console.WriteLine(lhm.PopFirst());
Console.WriteLine(lhm.PopFirst());
}
}
{
Dictionary<T, LinkedListNode<Tuple<U, T>>> D = new Dictionary<T, LinkedListNode<Tuple<U, T>>>();
LinkedList<Tuple<U, T>> LL = new LinkedList<Tuple<U, T>>();
LinkedList<Tuple<U, T>>.Enumerator myEnumerator;
{
//myEnumerator = LL.GetEnumerator();
foreach (var item in LL)
{
Console.WriteLine(item);
}
}
{
get
{
return D[c].Value.Item1;
}
{
if (D.ContainsKey(c))
{
LL.Remove(D[c]);
}
LL.AddLast(D[c]);
}
}
{
return D.ContainsKey(k);
}
{
var node = LL.First;
LL.Remove(node);
D.Remove(node.Value.Item2);
return node.Value.Item1;
}
{
get
{
return D.Count;
}
}
}
}
last updated: Sun 2022-04-03 2:52 AM