CurveKey removed useless code, CurveKey collection is now sorted and pass add tests

This commit is contained in:
SND\floAr_cp 2011-11-20 22:48:32 +00:00
parent 3f3aa57192
commit 108cc7fc03
2 changed files with 47 additions and 14 deletions

View File

@ -161,11 +161,11 @@ namespace ANX.Framework
{
return !a.Equals(b);
return a.Position != b.Position ||
/*return a.Position != b.Position ||
a.Value != b.Value ||
a.TangentIn != b.TangentIn ||
a.TangentOut != b.TangentOut ||
a.Continuity != b.Continuity;
a.Continuity != b.Continuity;*/
}
#endregion

View File

@ -96,18 +96,51 @@ namespace ANX.Framework
#endregion
#region Add
public void Add(CurveKey item)
{
if (item == null)
{
throw new ArgumentNullException();
}
keys.Add(item);
}
#endregion
#region Clear
public void Clear()
public void Add(CurveKey item)
{
if (item == null)
{
throw new ArgumentNullException();
}
// keys.Add(item);
if (this.keys.Count == 0)
{
//No list items
this.keys.Add(item);
return;
}
if (item.CompareTo(this[Count - 1]) > 0)
{
//Bigger than Max
this.keys.Add(item);
return;
}
int min = 0;
int max = Count - 1;
while ((max - min) > 1)
{
//Find half point
int half = min + ((max - min) / 2);
//Compare if it's bigger or smaller than the current item.
int comp = item.CompareTo(this[half]);
if (comp == 0)
{
//Item is equal to half point
this.keys.Insert(half, item);
return;
}
else if (comp < 0) max = half; //Item is smaller
else min = half; //Item is bigger
}
if (item.CompareTo(this[min]) <= 0) this.keys.Insert(min, item);
else this.keys.Insert(min + 1, item);
}
#endregion
#region Clear
public void Clear()
{
keys.Clear();
}