日期:2008-08-13 浏览次数:20421 次
#undef debug
#define debugdisplay
#undef debugdictionary
using System;
using System.Collections;
namespace LZW
{
public class cLZW
{
#region Constrcut
public cLZW()
{
}
#endregion
#region Coding
public string InCharStream
{
set { _InCharStream = value; }
get {return _InCharStream; }
}
public ArrayList CodingCodeStream
{
get {return _CodingCodeStream;}
}
public ArrayList CodingDictionary
{
get {return _CodingDictionary;}
}
private void InitCodingDictionary()
{
_CodingDictionary.Clear();
#if debug
_CodingDictionary.Add("A");
_CodingDictionary.Add("B");
_CodingDictionary.Add("C");
#else
for(int i = 0; i < 256; i++)
{
_CodingDictionary.Add((char)i);
}
#endif
}
private void AddCodingDictionary(object str)
{
_CodingDictionary.Add(str);
}
private void AddCodingCodeStream(object str)
{
_CodingCodeStream.Add(str);
}
private bool ISInCodingDictionary(string Prefix)
{
bool result = false;
int count = _CodingDictionary.Count;
for(int i = 0; i < count; i++)
{
string temp = _CodingDictionary[i].ToString();
if (temp.IndexOf(Prefix) >= 0)
{
result = true;
break;
}
}
return result;
}
private string GetIndexCodingDictionary(string Prefix)
{
string result ="0";
int count = _CodingDictionary.Count;
for(int i = 0; i < count; i++)
{
string temp = _CodingDictionary[i].ToString();
if (temp.IndexOf(Prefix) >= 0)
{
result = Convert.ToString(i + 1);
break;
}
}
return result;
}
private void DisplayCodingCodeStream()
{
System.Console.WriteLine("*********_CodingCodeStream************");
for(int i = 0; i < _CodingCodeStream.Count; i++)
{
System.Console.WriteLine(_CodingCodeStream[i].ToString());
}
}
private void DisplayCodingDictionary()
{
System.Console.WriteLine("*********_CodingDictionary************");
for(int i = 0; i < _CodingDictionary.Count; i++)
{
System.Console.WriteLine(_CodingDictionary[i].ToString());
}
}
private void DisplayInCharStream()
{
System.Console.WriteLine("*********_InCharStream************");
System.Console.WriteLine(_InCharStream);
}
private void InitCodingCodeStream()