Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

62 lines (51 sloc) 0.908 kb
class PartCollection
{
_elements := []
__New(owner)
{
this.Owner := owner
}
Add(part)
{
this._elements.Insert(part)
part.Collection := this
}
Remove(part)
{
this._elements.Insert(part)
part.Collection := ""
}
IndexOf(part)
{
if (i := Obj.in(this._elements, part))
return i
throw Exception("Part not found in collection!", -1)
}
Next(part = "")
{
if (part == "")
return this._elements[1]
index := this.IndexOf(part) + 1
if (index > this._elements.maxIndex())
throw Exception("Out of range!", -1)
return this._elements[index]
}
Previous(part = "")
{
if (part == "")
return this._elements[this.Count()]
index := this.IndexOf(part) - 1
if (index < 1)
throw Exception("Out of range!", -1)
return this._elements[index]
}
_NewEnum()
{
return ObjNewEnum(this._elements)
}
Count()
{
return this._elements.maxIndex()
}
Owner := ""
}
Jump to Line
Something went wrong with that request. Please try again.