diff --git a/CSharpTranslator/antlr3/src/cs2j/Utils/Set.cs b/CSharpTranslator/antlr3/src/cs2j/Utils/Set.cs new file mode 100644 index 0000000..ded0857 --- /dev/null +++ b/CSharpTranslator/antlr3/src/cs2j/Utils/Set.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace RusticiSoftware.Translator.Utils +{ + public class Set : IEnumerable + { + + /// + /// Provides the storage for elements in the Set, stored as the key-set + /// of a Dictionary object. + /// + protected Dictionary setD = null; + private readonly static object PlaceholderObject = new object(); + + public Set() + { + setD = new Dictionary(); + } + + + public IEnumerator GetEnumerator() + { + return setD.Keys.GetEnumerator(); + } + + + /// + /// The placeholder object used as the value for the Dictionary object. + /// + /// There is a single instance of this object globally, used for all Sets. + /// + protected object Placeholder + { + get { return PlaceholderObject; } + } + + + /// + /// Adds the specified element to this set if it is not already present. + /// o: The object to add to the set. + /// returns true if the object was added, false if it was already present. + public bool Add(T s) + { + if (setD.ContainsKey(s)) + return false; + else + { + //The object we are adding is just a placeholder. The thing we are + //really concerned with is 'o', the key. + setD[s] = PlaceholderObject; + return true; + } + } + + public T[] AsArray() + { + ICollection keys = setD.Keys; + T[] retArr = new T[keys.Count]; + + keys.CopyTo(retArr, 0); + + return retArr; + } + } +} diff --git a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj index 5b77611..86e6dcf 100644 --- a/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj +++ b/CSharpTranslator/antlr3/src/cs2j/cs2j.csproj @@ -39,7 +39,7 @@ DEBUG;TRACE prompt 4 - -translator-timestamp-files=false -translator-keep-parens=false -netdir=/Users/keving/gitrepos/cs2j/CS2JLibrary/NetFramework/ -dumpxmls -xmldir=/Users/keving/tmp/xml/se -odir=/Users/keving/tmp/java/se/src /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/Logic/Integration/ExternalId.cs + -translator-timestamp-files=false -translator-keep-parens=false -netdir=/Users/keving/gitrepos/cs2j/CS2JLibrary/NetFramework/ -dumpxmls -xmldir=/Users/keving/tmp/xml/se -odir=/Users/keving/tmp/java/se/src /Users/keving/svnrepos/ScormEngineNet/src/app/ScormEngine.Core/Logic/Integration/ExternalConfiguration.cs pdbonly @@ -70,6 +70,7 @@ +