From b0760b28807b31cc1403584265c07feb87ac4887 Mon Sep 17 00:00:00 2001 From: Treeki Date: Fri, 18 Feb 2011 03:28:31 +0100 Subject: some collada work, and an unfinished OGL renderer using OpenTK. huge commit --- NW4RTools/Util/IOrderedDictionary.cs | 2 ++ NW4RTools/Util/OrderedDictionary.cs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'NW4RTools/Util') diff --git a/NW4RTools/Util/IOrderedDictionary.cs b/NW4RTools/Util/IOrderedDictionary.cs index 6cf9b85..31a61eb 100644 --- a/NW4RTools/Util/IOrderedDictionary.cs +++ b/NW4RTools/Util/IOrderedDictionary.cs @@ -58,5 +58,7 @@ namespace NW4RTools.Util TKey GetKeyForIndex(int index); + TKey GetKeyForValue(TValue value); + int GetIndexForValue(TValue value); } } diff --git a/NW4RTools/Util/OrderedDictionary.cs b/NW4RTools/Util/OrderedDictionary.cs index 98e523a..0463d33 100644 --- a/NW4RTools/Util/OrderedDictionary.cs +++ b/NW4RTools/Util/OrderedDictionary.cs @@ -171,6 +171,24 @@ namespace NW4RTools.Util return List[index].Key; } + public TKey GetKeyForValue(TValue value) { + foreach (var kv in List) { + if (kv.Value.Equals(value)) + return kv.Key; + } + throw new KeyNotFoundException(); + } + + public int GetIndexForValue(TValue value) { + int i = 0; + foreach (var kv in List) { + if (kv.Value.Equals(value)) + return i; + i += 1; + } + throw new KeyNotFoundException(); + } + /// /// Inserts a new entry into the OrderedDictionary<TKey,TValue> collection with the specified key and value at the specified index. /// -- cgit v1.2.3