new ListType(parameters)
- Description:
Specifies a list type, i.e. an strictly ordered container of elements.
Extends: Type. This class extends Type, with all public methods available.
Type parameters
General parameters
name: ...
The type name. By default the type name islist-of-$itemType
.itemType: ...
The type elements if any. By default, "value", means any value.
Parameters for the syntactic projection
minLength: ...
The minimal number of items in the list. By default0
.maxLength: ...
The maximal number of items in the list. By default unbounded (-1
).
Parameters for the cost calculation
deleteCost: ...
The non-negative deleting cost value.- By default uses the
getDistance()
between the item and an empty data structure.
- By default uses the
insertCost: ...
The non-negative inserting cost value.- By default equals to the
deleteCost
.
- By default equals to the
editCost: ...
The non-negative editing cost value.- By default uses the
getDistance()
between each item.
- By default uses the
ListType specification
Syntactic projection - If the value is empty, it corresponds to an empty list.
- If the value is not a list, it is encapsulated in a [ value ] singleton.
- If the list length is not in the (optional) [minLength, maxLength] bounds a message is issued, but the list is neither truncated nor extended.
- Each list item is syntactically projected.Semantic projection - Each list item is semantically projected. Distance value - The minimal distance is computed using the Levenshtein distance calculation applied on the list element and delegating the edition cost to the item Type distance computation.
- The algorithmic complexity order of magnitude is thus quadratic with respect to the list length considering the item type complexity as basic operation.
- The editing distance can be either:
- parameterized defining fixed deletion, insertion and editing costs, or
- parameterized rederiving the cost() function.Geodesic path - The geodesic path corresponds to the Wagner-Fischer algorithm shortest path in the matrix distance yielding to the minimal distance computation. Comparison - Returns 0 If each element pair compares equal and both lists have the same length.
- Returns <0 If either the value of the first item that does not match is lower in the left hand side list, or all compared items match but the left hand side list is shorter.
- Returns >0 If either the value of the first item that does not match is greater in the left hand side list, or all compared items match but the left hand side list is longer.Bounds - Considers all list lengths beetwen `minLength` and `maxLength` to calculate the bounds, from the item type bounds.
Parameters:
Name | Type | Description |
---|---|---|
parameters |
JSON | String | The type parameters. |
Methods
cost(what, lhs, i, rhs, j) → {double}
- Description:
Cost function of the editing distance
- The
ListType::cost()
implements thedeleteCost
,insertCost
andeditCost
parameters related cost. - A typical re-implementation is of the form:
class MyListType : public ListType { ../.. double cost(char what, JSON lhs, unsigned int i, JSON rhs, unsigned int j) const { // Implements the MyListType specific features, if appropriate and returns the value return ListType::cost(what, lhs, i, rhs, j); // Delegates to the parent implementation otherwise } }
- The
Parameters:
Name | Type | Description |
---|---|---|
what |
char | The editing operation:
|
lhs |
Value | The left hand-size value. |
i |
uint | The lhs index. |
rhs |
Value | The right hand-size value. |
j |
uint | The rhs index. |
Returns:
The cost value.
- Type
- double