Difference between revisions of "User:PROXiCiDE/MathUtil"

Jump to navigation Jump to search
1,790 bytes added ,  20:48, 27 April 2014
→‎Requires SKSE: Added BitArray
imported>PROXiCiDE
imported>PROXiCiDE
(→‎Requires SKSE: Added BitArray)
Line 178: Line 178:
Return 0
Return 0
EndIf
EndIf
EndFunction
</source>
==Bit Array==
Bit Array supports a maximum of 512 Bits
<source lang="papyrus">
Int[] Function Bit_CreateArray(Int aiSize)
If aiSize == 1
Return New Int[2]
ElseIf aiSize == 2
Return New Int[3]
ElseIf aiSize == 3
Return New Int[4]
ElseIf aiSize == 4
Return New Int[5]
ElseIf aiSize == 5
Return New Int[6]
ElseIf aiSize == 6
Return New Int[7]
ElseIf aiSize == 7
Return New Int[8]
ElseIf aiSize == 8
Return New Int[9]
ElseIf aiSize == 9
Return New Int[10]
ElseIf aiSize == 10
Return New Int[11]
ElseIf aiSize == 11
Return New Int[12]
ElseIf aiSize == 12
Return New Int[13]
ElseIf aiSize == 13
Return New Int[14]
ElseIf aiSize == 14
Return New Int[15]
ElseIf aiSize == 15
Return New Int[16]
ElseIf aiSize == 16
Return New Int[17]
ElseIf aiSize == 17
Return New Int[18]
ElseIf aiSize == 18
Return New Int[19]
EndIf
EndFunction
Int[] Function BitArray_New(Int aiSize)
Int iSize = Math.Ceiling(ClampInt(aiSize,30,512) / 30)
Int[] iResults = Bit_CreateArray(iSize)
iResults[0] = aiSize
Int i = 1
While (i < iResults.Length)
iResults[i] = 0
i += 1
EndWhile
Return iResults
EndFunction
Function BitArray_Set(Int[] aiBitCTX, Int aiIndex)
Int iIndex = Math.Ceiling(aiIndex / 30)
aiBitCTX[iIndex] = Bit_Set(aiBitCTX[iIndex], aiIndex)
EndFunction
Bool Function BitArray_Get(Int[] aiBitCTX, Int aiIndex)
Int iIndex = Math.Ceiling(aiIndex / 30)
Return Bit_Get(aiBitCTX[iIndex], aiIndex)
EndFunction
Function BitArray_Xor(Int[] aiBitCTX, Int aiIndex)
Int iIndex = Math.Ceiling(aiIndex / 30)
aiBitCTX[iIndex] = Bit_Xor(aiBitCTX[iIndex], aiIndex)
EndFunction
Function BitArray_Clear(Int[] aiBitCTX, Int aiIndex)
Int iIndex = Math.Ceiling(aiIndex / 30)
aiBitCTX[iIndex] = Bit_Clear(aiBitCTX[iIndex], aiIndex)
EndFunction
EndFunction
</source>
</source>
Anonymous user

Navigation menu