-
Notifications
You must be signed in to change notification settings - Fork 72
/
class_Linear.ahk
93 lines (93 loc) · 2.46 KB
/
class_Linear.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Class Linear extends Lib.obj.Array.Generic{
Clone(Arr*) {
For i, sArr in Arr {
tOut:=Array()
For index,value in sArr
if(!Lib.obj.isMetaInfo(index,value))
tOut.push(value)
Arr[i]:=tOut
}
return this.Helper.Return_format(Arr)
}
join(delim:=",",Arr*) {
this.Helper.Default_Param(Arr,",",delim)
For i,sArr in Arr {
For si,Val in sArr
Out.=delim (isobject(Val)?Lib.Obj.Array.ToString(Val):Val)
Arr[i]:=SubStr(Out,StrLen(delim) + 1), Out:=""
}
return this.Helper.Return_format(Arr)
}
/*
trim_instruction:
1 - Remove at beginning of array
0 - remove value at end of array
an array of instructions can be input and they will be cycled through
*/
Trim(trim_instruction,size,Arr*) { ;Needs updated so trim_instruction uses CSV
if(!isobject(trim_instruction))
trim_instruction:=[trim_instruction,trim_instruction]
For i,sArr in Arr {
increment:=1
if(this.Length(sArr) > size)
While(this.Length(sArr) > size) {
inst_num:=Mod(increment,trim_instruction.length()) + 1
increment++
if(trim_instruction[inst_num] == 1)
remval:=sArr.RemoveAt(1)
else
remval:=sArr.pop()
if(Lib.obj.isMetaInfo(remval)) {
Random rando, 1, % sArr.Length()
sArr.InsertAt(rando,remval)
}
}
Arr[i]:=sArr
}
return this.Helper.Return_format(Arr)
}
Split(Split_Index, Arr*) {
Arr.push("")
Arr:=this.Clone(Arr*)
Arr.pop()
For i,sArr in Arr {
Arr[i]:=[sArr.clone(),sArr.Clone()]
Arr[i][1].removeAt(Split_Index,sArr.Length())
Arr[i][2].removeAt(1,Split_Index - 1)
}
return this.Helper.Return_format(Arr)
}
Length(Arr*) {
For i,sArr in Arr {
length:=0
For index,value in sArr
if(!Lib.obj.isMetaInfo(index,value))
length++
Arr[i]:=Length
}
return this.Helper.Return_format(Arr)
}
removeAll(value, Arr*) {
For i,sArr in Arr {
rval_index:=""
Loop % sArr.length()
if(sArr[A_Index] == value)
rval_index.="|" A_Index
StringTrimLeft, Purge,Purge,1
Sort rval_index, N R D|
Loop, Parse, rval_index ,|
Arr[i].removeAt(A_LoopField)
}
return this.Helper.Return_format(Arr)
}
toString(Arr*){
for i,sArr in Arr {
Loop % sArr.length()
if(!Lib.obj.isMetaInfo(A_Index,sArr[A_Index]))
sOut.= ", " Lib.Obj.Array.toString(sArr[A_Index])
StringTrimLeft,sOut,sOut,1
Arr[i]:="[" sOut "]"
}
return this.Helper.Return_format(Arr)
}
}