|
From: Andreas B. <an...@se...> - 2006-08-27 19:01:45
|
Hi,
If we cannot omit the check whether the key exists before adding a new =
one, I'd prefer some short prefix constructed from the uint counter or =
as Borrilis suggested, using GetHashCode() of the final key value to =
prepend to it, i.e. not using a GUID.
Then, in order not to replicate a commonly used naming scheme which was =
the request, what about just swap the ("TypeName" + counter) order and =
use (counter + "TypeName") ? :-)
Simpliest, fastest.
Yet to the AxiomCollection.Remove(T item) method, it could by improved =
for speed.=20
Instead of this:
public void Remove( T item )
{
if ( this.ContainsValue( item ) )
{
int index =3D this.IndexOfValue( item );
this.RemoveAt( index );
}
}
we should use this (the value needs not to be searched two times + some =
checks):
public void Remove( T item )
{
if (item =3D=3D null)
throw new ArgumentNullException("Can't remove a null =
item from a collection.");
int index =3D this.IndexOfValue( item );
if ( index >=3D 0 )
{
this. RemoveAt( index );
}
else
throw new AxiomException( "The specified item was not =
found in the collection." );
}
If you want I can make a suggestion of how the new AxiomCollection might =
look like as whole, the question still is how to create the unique =
string key...
|