-
Notifications
You must be signed in to change notification settings - Fork 11
Class Templates
Templates may have multiple implementations of a class indicated by the "implements" tag. In the example below <nodeType> is a placeholder for the type name, which is specified when the class is instantiated, in this case type <int>.
If there are multiple implementations you can use the "specs=" tag to specify features or Big-O requirements then CodeDog will choose an appropriate implementation for your platform and language. Conversely if you provide an implementation of a template you can specify the features and Big-O complexity it provides.
Keywords are as follows:
- ['polynomial'or'exponential', 'nLog_n', 'linear', 'logarithmic', 'constant']
Or you can use corresponding keywords:
- ['verySlow', 'slow', 'normal', 'fast', 'veryFast']
Notice in this example myList1 specifies that the append function operates "fast", which corresponds to "logarithmic" while myList2 specifies it is "veryFast" corresponding to "constant".
struct myList1<nodeType>: implements = List specs = {append = fast}{
void: append(me nodeType: item) <- {}
}
struct myList2<nodeType>: implements = List specs = {append = veryFast}{
void: append(me nodeType: item) <- {}
}
struct GLOBAL{
void: runProg()<-{
me List<int: append = veryFast>: intList
intList.append(5)
}
}