|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcodesimian.CS<CSGeneric>
codesimian.DefaultCS
codesimian.SimpleList
codesimian.StringTree
public class StringTree
A tree whose internal nodes are simple lists and whose leafs are strings (class S).
This allows any string to have chars or other strings efficiently inserted anywhere
or any range or subset efficiently deleted.
The childs of a node in this tree must be hidden,
because the visible childs are mapped from tree nodes below.
Every char in every string in every position in the tree has a unique index in the root.
root.PC(57) returns char number 57, found somewhere within the tree, but it appears to be in the root.
This is recursively true for any node in the tree.
When this string gets too big, should automaticly split childs[] into a larger array,
creating new StringTrees to fill the new indexs.
THIS CLASS IS NOT FINISHED.
When its done, TextAreaCS.java could become much faster by storing its string as a StringTree
and only calling the paint() function every 50 milliseconds or every textlength/30 chars whichever is shorter.
THIS CLASS COULD BE MADE MUCH MORE EFFICIENT BY DIRECTLY IMPLEMENTING ALL FUNCTIONS IN THE codesimian.CodeSimian interface.
COULD ALSO BE MORE EFFICIENT BY IMPLEMENTING L AND SETL FOR ALL PRIMITIVE ARRAY TYPES.
STRANGE ERRORS COULD OCCUR WITH ARRAYS OF STRINGS.
WARNING: if the tree (branching with the hidden childs[] array) becomes a network
and that network contains a CYCLE then infinite loops will occur. Networks without cycles are ok.
Since this is a tree where leafs are usually S objects, P(int) should return objects from the constant-pool.
Field Summary |
---|
Fields inherited from class codesimian.CS |
---|
DESCRIPTION, END, EXECPROXY, HEAP, JAVACODE, MYFUEL, NAME, NEWINSTANCE, NULL, PARENT, PARSEPRIORITY, PREV, TESTER, THIS |
Constructor Summary | |
---|---|
StringTree()
Deprecated. |
|
StringTree(CS[] childs)
Deprecated. |
Method Summary | |
---|---|
int |
approximateheight(int randomPathsToMeasure)
Deprecated. Returns the approximate height of this StringTree as a tree node above its lowest leaf. |
int[] |
childSizes()
Deprecated. |
int |
countP()
Deprecated. Quantity of params. |
boolean |
deleteP(int index)
Deprecated. WARNING: if returns false, could have deleted but not moved other params down 1 index. WARNING: if duplicates not allowed, can not slide params down 1 index the standard way, returns false. |
double |
DForProxy()
Deprecated. returns this.countP(). |
boolean |
insertP(int index,
CS ins)
Deprecated. same as setP(int,CS) but inserts instead of overwriting. |
byte |
isIllusion(int index)
Deprecated. Describes if the CS in an index is an illusion or not. |
boolean |
isLeaf(CS treeNode)
Deprecated. a hack, checks if treeNode instanceof S, the default string type. |
java.lang.String |
keyword()
Deprecated. For the CodeSimian language as a String. CodeSimian language keyword, like "+" "*" "max" ">" etc. Override this function if you want to specify a keyword other than how I derive them from the class name, like + for Add. Some CSs might never be intended to be used in the language by their keyword. The best example (4/05) is Num, because it is used in the language like "3.4" instead of "num()". |
int |
maxP()
Deprecated. Maximum quantity of Params |
boolean |
mergeSmallest2Childs()
Deprecated. |
int |
minP()
Deprecated. For DForProxy(). Minimum number of parameters in param[] needed to call DForProxy(). Defines which indexs of param[] DForProxy() can use. Functions with a different number of parameters must override this. OVERRIDE THIS FUNCTION IF EXEC USES A DIFFERENT NUMBER OF PARAMETERS. Default is 1. |
CS |
P(int index)
Deprecated. WARNING: if add CSs then delete them, they are still in the param[] array and can be returned in this function, despite them being out of valid range: index at least countP(). |
boolean |
pushDownChilds(int start,
int quantity)
Deprecated. removes a range of childs and replaces them with 1 new StringTree containing them |
boolean |
reshapeTree()
Deprecated. returns true if tree was changed to have a better shape, like moving chars from a big node to a smaller node |
boolean |
setP(int index,
CS setTo)
Deprecated. Every CS is a list of other CSs, between size minP() and maxP() inclusive. |
boolean |
splitBiggestChild()
Deprecated. |
int |
splitBigLeafs()
Deprecated. splits leafs that are bigger than maxLeafSize, increasing childs.length by 1 |
Methods inherited from class codesimian.DefaultCS |
---|
B, C, decrementMyFuel, description, F, fuel, getExec, getObject, heap, I, indexP, indexPName, insertB, insertC, insertD, insertF, insertI, insertJ, insertL, insertL, insertL1, insertS, insertZ, J, javaCode, LForProxy, LForProxy, myFuel, name, newInstance, objectToCS, objectToCSArray, objectToCSArray, prevD, prevL, PType, S, setB, setC, setCountP, setD, setD, setExec, setF, setFuel, setI, setJ, setL, setL, setL, setL1, setMyFuel, setName, setObject, setPrevExec, setPType, setS, setZ, start, toString, V, Z |
Methods inherited from class codesimian.CS |
---|
addB, addC, addD, addF, addI, addJ, addL, addP, addP, addP, addP, addP, addS, addZ, BForProxy, CForProxy, clone, cost, D, deleteP, FForProxy, GETB, GETC, GETD, GETF, GETI, GETJ, GETL, GETS, GETZ, IForProxy, JForProxy, L, L, L, L, L, maxD, minD, overwrites, parent, parsePriority, PB, PC, PD, PF, PI, PJ, PL, prevB, prevC, prevF, prevI, prevJ, prevS, prevZ, proxyOf, PS, PZ, reflect, reflect, reflect6, setB, SETB, setC, SETC, setCost, SETD, setDescription, setF, SETF, setHeap, setI, SETI, setJ, SETJ, SETL, setL, setL, setParent, setParsePriority, setProxyOf, setS, SETS, setTester, setZ, SETZ, SForProxy, tester, toJavaCode, VForProxy, voidReflect, ZForProxy |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StringTree()
public StringTree(CS[] childs)
Method Detail |
---|
public double DForProxy()
SimpleList
DForProxy
in class SimpleList
public java.lang.String keyword()
DefaultCS
keyword
in class SimpleList
CS.parent()
,
CS.newInstance()
,
CS.name()
public int minP()
DefaultCS
minP
in class SimpleList
public int maxP()
CS
maxP
in class SimpleList
public int countP()
CS
countP
in class DefaultCS
public CS P(int index)
DefaultCS
P
in class DefaultCS
index
- range 0 (or neg?) to countP()-1 inclusiveCS.heap()
public boolean setP(int index, CS setTo)
CS
setP
in class DefaultCS
public boolean insertP(int index, CS ins)
CS
insertP
in class DefaultCS
public boolean deleteP(int index)
DefaultCS
deleteP
in class DefaultCS
public byte isIllusion(int index)
CS
isIllusion
in class CS
CS.overwrites(int)
,
S.isIllusion(int)
public boolean reshapeTree()
public boolean mergeSmallest2Childs()
public boolean splitBiggestChild()
public boolean pushDownChilds(int start, int quantity)
public int splitBigLeafs()
public int[] childSizes()
public boolean isLeaf(CS treeNode)
public int approximateheight(int randomPathsToMeasure)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |