47 lines
676 B
C#
47 lines
676 B
C#
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace lib
|
|
{
|
|
[Serializable]
|
|
public struct Token
|
|
{
|
|
public string str { get{ return m_str; } }
|
|
|
|
public Token( String str )
|
|
{
|
|
m_str = str;
|
|
m_hash = m_str.GetHashCode();
|
|
}
|
|
|
|
public override bool Equals( object obj )
|
|
{
|
|
if( !( obj is Token ) )
|
|
return false;
|
|
|
|
//This doesnt use as because Token is a struct
|
|
var otherId = (Token)obj;
|
|
|
|
if( m_hash != otherId.m_hash )
|
|
return false;
|
|
|
|
return m_str == otherId.m_str;
|
|
}
|
|
|
|
|
|
public bool Equals_fast( Token other )
|
|
{
|
|
return m_hash == other.m_hash && m_str == other.m_str;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return m_hash;
|
|
}
|
|
|
|
int m_hash;
|
|
String m_str;
|
|
}
|
|
|
|
}
|