[Python.NET] Using a .Net DLL

Sean McKay mckay_sean at yahoo.com
Fri Mar 12 16:14:39 EST 2004


My apologies!  I'll add the Dict code.. (btw, some closing brackets are
probably missing, as well as possibly some using statements, I was trying
to cut stuff out for brevity).  Thanks for looking at this...
Sean

using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;

namespace nltk
{
	namespace probability
	{

		public delegate ProbDist CreateProbDistDelegate(FreqDist fdist, params
object[] args);

		#region Helper Classes

		public class Dict: Hashtable  
		{
			private ArrayList keys = new ArrayList();

			public override object this[ object key ]  
			{
				get  
				{
					return( base[key] );
				}
				set  
				{
					if (!keys.Contains(key))
						keys.Add(key);
					base[key] = value;
				}
			}

			public string[] GetKeys 
			{
				get  
				{
					string[] results = new string[keys.Count];
					keys.CopyTo(results);
					return( results);
				}
			}

			public override string ToString()
			{
				string result = "";
				foreach (string key in Keys)
				{
					result += key + ":" + base[key].ToString() + " ";
				}
				return result;
			}

			public override void Add( object key, object value )  
			{
				if (!keys.Contains(key))
					keys.Add(key);
				base.Add(key, value);
			}
	
			public override void Remove( object key )  
			{ 
				keys.Remove(key);
				base.Remove( key );
			}

			public int Length
			{
				get
				{
					return base.Count;
				}
			}
		}


		#endregion


--- Thane <thane at magna-capital.com> wrote:
> Sean, I can't get your C# code to compile.  The complaint is about
> "Dict".
> 
<snipped>

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com



More information about the PythonDotNet mailing list