( Inherits from MfObject )
Abstract Class
MfEnumerableBase exposes the enumerator, which supports a simple iteration over a collection.
MfEnumerableBase is an abstract class and must be inherited by other classes such as MfList.
Name |
Description |
|
Constructor for Abstract MfEnumerableBase Class |
Name |
Description |
|
Returns a new enumerator to enumerate this object's key-value pairs. This method is usually not called directly, but by the for-loop or by GetEnumerator() |
||
Adds MfAttribute extended items to extended classes. Inherited from MfObject. |
||
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. Inherited from MfObject. |
||
Compares obj to current instance to see if they are the same. Inherited from MfObject. |
||
Gets an MfAttribute of the class. Inherited from MfObject. |
||
Gets a MfGenericList of MfAttribute that Contains the attributes for the current class instance. Inherited from MfObject. |
||
Gets an enumerator |
||
Gets the zero-based index value of the position of MfAttribute within the instance of the class. Inherited from MfObject. |
||
Gets the Type for the for the Class .Inherited from MfObject. |
||
Gets if the current instance of class derived from MfSystemException has MfAttribute. Inherited from MfObject. |
||
Gets if current instance of object is of the same type. Inherited from MfObject. Inherited from MfObject. |
||
Get if the current class is an instance. Inherited from MfObject. |
||
Creates a shallow copy of the current MfObject instance. Inherited from MfObject. |
||
Gets a string representation of the MfObject. Inherited from MfObject. |
||
Verifies the the current object is set to an instance. Inherited from MfObject. |
||
VerifyIsNotInstance([MethodName, LineFile, LineNumber, Source]) |
Verifies the the current object is NOT set to an instance. Used in Static methods. Inherited from MfObject. |
class TheList extends MfEnumerableBase
{
m_InnerList := Null
m_Enum := Null
__New() {
base.__New()
this.m_isInherited := this.__Class != "TheList"
this.m_InnerList := []
this.m_InnerList.Count := 0
this.m_Enum := Null
}
Add(obj) {
_newCount := this.m_InnerList.Count + 1
this.m_InnerList[_newCount] := obj
this.m_InnerList.Count := _newCount
retval := _newCount - 1
return retval
}
Clear() {
this.m_InnerList := Null
this.m_InnerList := []
this.m_InnerList.Count := 0
this.m_Enum := Null
}
Insert(index, obj) {
_index := MfInteger.GetValue(index)
if ((_index < 0) || (_index > this.m_InnerList.Count))
{
ex := new MfArgumentOutOfRangeException("index", MfEnvironment.Instance.GetResourceString("ArgumentOutOfRange_Index"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
If (_index = this.m_InnerList.Count)
{
this.Add(obj)
return
}
i := _index + 1 ; step up to one based index for AutoHotkey array
this.m_InnerList.InsertAt(i, obj)
this.m_InnerList.Count ++
}
RemoveAt(index) {
_index := MfInteger.GetValue(index)
if ((_index < 0) || (_index >= this.m_InnerList.Count)) {
ex := new MfArgumentOutOfRangeException("index", MfEnvironment.Instance.GetResourceString("ArgumentOutOfRange_Index"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
i := _index + 1 ; step up to one based index for AutoHotkey array
vRemoved := this.m_InnerList.RemoveAt(i)
if (vRemoved) {
this.m_InnerList.Count -- ; lower the count by one
} else {
ex := new MfException(MfEnvironment.Instance.GetResourceString("Exception_FailedToRemove"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
}
Count[]
{
get {
return this.m_InnerList.Count
}
set {
ex := new MfNotSupportedException(MfEnvironment.Instance.GetResourceString("NotSupportedException_readonly_Property"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
}
Item[index]
{
get {
_index := MfInteger.GetValue(Index)
if (_index < 0 || _index >= this.Count) {
ex := new MfArgumentOutOfRangeException(MfEnvironment.Instance.GetResourceString("ArgumentOutOfRange_Index"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
_index ++ ; increase value for one based array
return this.m_InnerList[_index]
}
set {
_index := MfInteger.GetValue(Index)
if (_index < 0 || _index >= this.Count) {
ex := new MfArgumentOutOfRangeException(MfEnvironment.Instance.GetResourceString("ArgumentOutOfRange_Index"))
ex.SetProp(A_LineFile, A_LineNumber, A_ThisFunc)
throw ex
}
_index ++ ; increase value for one based array
this.m_InnerList[_index] := value
return this.m_InnerList[_index]
}
}
_NewEnum() {
return new TheList.Enumerator(this)
}
class Enumerator
{
m_Parent := Null
m_KeyEnum := Null
m_index := 0
m_count := 0
__new(ParentClass) {
this.m_Parent := ParentClass
this.m_count := this.m_Parent.Count
}
Next(ByRef key, ByRef value)
{
if (this.m_index < this.m_count) {
key := this.m_index
value := this.m_Parent.Item[key]
}
this.m_index++
if (this.m_index > (this.m_count)) {
return 0
} else {
return true
}
}
}
}