[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-396-g6f4d019
ontologiae
ontologiae at ordinateur-de-ontologiae.local
Sun Aug 16 15:42:24 UTC 2009
The following commit has been merged in the master branch:
commit 6f4d01962e6e25dd2d9e01c5cb54c43a02f82dcc
Author: ontologiae <ontologiae at ordinateur-de-ontologiae.local>
Date: Sun Aug 16 17:42:00 2009 +0200
collection doc update
diff --git a/lib2/collection/low_level/collection.li b/lib2/collection/low_level/collection.li
index dc7f037..e34be9b 100644
--- a/lib2/collection/low_level/collection.li
+++ b/lib2/collection/low_level/collection.li
@@ -30,19 +30,19 @@ Section Header
// Such a collection is traversable using a simple INTEGER index from `lower'
// to `upper' using `item'. All COLLECTIONs are resizable thanks to
// `add_last' / `remove_last', `add_first' / `remove_first' as well as
- // `add' / `remove' .
+ // `add' / `remove' .<br/> <br/>
//
// This abstraction provides feature to view a COLLECTION as a stack
// (as an example by using `add_last', `last', and `remove_last').
// One can also use a COLLECTION as a queue (as an example, by using
- // `add_last', `first' and `remove_first').
+ // `add_last', `first' and `remove_first').<br/> <br/>
//
// The Lisaac standard library provides five implementations of COLLECTION:
- // ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST. Except for creations all
+ // ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST. <br/> Except for creations all
// implementations have exactly the same behavior. Switching from one
// implementation to another only change the memory used and the execution
// time (see header comment of ARRAY, FAST_ARRAY, LINKED_LIST and LINKED2_LIST
- // for more details).
+ // for more details).<br/> <br/>
Section Inherit
@@ -58,8 +58,10 @@ Section Public
- item i:INTEGER :V <-
// Item at the corresponding index `i'.
- //
- // See also `lower', `upper', `valid_index', `put', `swap'.
+ // * Description en Francais : Item à l'index `i'
+ // * See: `lower', `upper', `valid_index', `put', `swap'
+ // * Require : None
+ // * Ensure : None
( + result:V;
deferred;
@@ -72,8 +74,7 @@ Section Public
- put element:V to i:INTEGER <-
// Make `element' the item at index `i'.
- //
- // See also `lower', `upper', `valid_index', `item', `swap', `force'.
+ // * See: `lower', `upper', `valid_index', `item', `swap', `force'.
[
-? { valid_index i };
]
@@ -87,8 +88,7 @@ Section Public
- swap i1:INTEGER with i2:INTEGER <-
// Swap item at index `i1' with item at index `i2'.
- //
- // See also `item', `put'.
+ // * See: `item', `put'.
[
-? { valid_index i1 };
-? { valid_index i2 };
@@ -107,8 +107,7 @@ Section Public
- set_all_with v:V <-
// Set all items with value `v'.
- //
- // See also `set_slice_with'.
+ // * See: `set_slice_with'.
(
deferred;
)
@@ -118,8 +117,7 @@ Section Public
- set_slice lower_index:INTEGER to upper_index:INTEGER with v:V <-
// Set all items in range [`lower_index' .. `upper_index'] with `v'.
- //
- // See also `set_all_with'.
+ // * See: `set_all_with'.
[
-? { lower_index <= upper_index };
-? { valid_index lower_index };
@@ -137,7 +135,6 @@ Section Public
- clear_all <-
// Set every item to its default value.
// The `count' is not affected
- //
// see also `clear', `all_default'.
( + value:V;
@@ -157,7 +154,7 @@ Section Public
// Add a new item in first position : `count' is increased by
// one and all other items are shifted right.
//
- // See also `add_last', `first', `last', `add'.
+ // * See: `add_last', `first', `last', `add'.
(
deferred;
)
@@ -171,7 +168,7 @@ Section Public
- add_last element:V <-
// Add a new item at the end : `count' is increased by one.
//
- // See also `add_first', `last', `first', `add'.
+ // * See: `add_first', `last', `first', `add'.
(
deferred;
)
@@ -187,7 +184,7 @@ Section Public
// by one and range [`index' .. `upper'] is shifted right
// by one position.
//
- // See also `add_first', `add_last', `append_collection'.
+ // * See: `add_first', `add_last', `append_collection'.
[
-? { index.in_range lower to (upper + 1)};
]
@@ -203,7 +200,7 @@ Section Public
- append_collection other:COLLECTION(V) <-
// Append `other' to Current.
//
- // See also `add_last', `add_first', `add'.
+ // * See: `add_last', `add_first', `add'.
[
-? { other != NULL };
]
@@ -225,7 +222,7 @@ Section Public
// necessary (new bounds except `index' are initialized with
// default values).
//
- // See also `put', `item', `swap'.
+ // * See: `put', `item', `swap'.
[
+? { index >= lower};
]
@@ -263,7 +260,7 @@ Section Public
- remove_first <-
// Remove the `first' element of the collection.
//
- // See also `remove_last', `remove', `remove_head'.
+ // * See: `remove_last', `remove', `remove_head'.
[
-? { ! is_empty };
]
@@ -278,7 +275,7 @@ Section Public
- remove_head n:INTEGER <-
// Remove the `n' elements of the collection.
//
- // See also `remove_tail', `remove', `remove_first'.
+ // * See: `remove_tail', `remove', `remove_first'.
[
-? {n > 0};
-? {n <= count};
@@ -295,7 +292,7 @@ Section Public
// Remove the item at position `index'. Followings items
// are shifted left by one position.
//
- // See also `remove_first', `remove_head', `remove_tail', `remove_last'.
+ // * See: `remove_first', `remove_head', `remove_tail', `remove_last'.
[
-? { valid_index index };
]
@@ -310,7 +307,7 @@ Section Public
- remove_last <-
// Remove the `last' item.
//
- // See also `remove_first', `remove', `remove_tail'.
+ // * See: `remove_first', `remove', `remove_tail'.
[
-? {! is_empty};
]
@@ -325,7 +322,7 @@ Section Public
- remove_tail n:INTEGER <-
// Remove the last `n' item(s).
//
- // See also `remove_head', `remove', `remove_last'.
+ // * See: `remove_head', `remove', `remove_last'.
[
-? {n > 0};
-? {n <= count};
@@ -341,7 +338,7 @@ Section Public
- clear <-
// Discard all items in order to make it `is_empty'.
//
- // See also `clear_all'.
+ // * See: `clear_all'.
(
deferred;
)
@@ -356,7 +353,7 @@ Section Public
- has x:V :BOOLEAN <-
// Look for `x' using `equal' for comparison.
//
- // See also `fast_has', `index_of start', `fast_index_of start'.
+ // * See: `fast_has', `index_of start', `fast_index_of start'.
(
valid_index (first_index_of x)
);
@@ -364,7 +361,7 @@ Section Public
- fast_has x:V :BOOLEAN <-
// Look for `x' using basic `=' for comparison.
//
- // See also `has', `fast_index_of start', `index_of start'.
+ // * See: `has', `fast_index_of start', `index_of start'.
(
valid_index (fast_first_index_of x)
);
@@ -405,7 +402,7 @@ Section Public
// of `element' at or after `start_index'. Answer `upper + 1' when `element'
// when the search fail.
//
- // See also `fast_index_of', `reverse_index_of', `first_index_of'.
+ // * See: `fast_index_of', `reverse_index_of', `first_index_of'.
(
deferred;
0
@@ -421,7 +418,7 @@ Section Public
// which means from the `start_index' down to the `lower' index .
// Answer `lower -1' when the search fail.
//
- // See also `fast_reverse_index_of', `last_index_of', `index_of'.
+ // * See: `fast_reverse_index_of', `last_index_of', `index_of'.
[
-? { valid_index start_index };
]
@@ -440,7 +437,7 @@ Section Public
// which means from the `upper' down to the `lower' index . Answer `lower -1'
// when the search fail.
//
- // See also `fast_last_index_of', `reverse_index_of', `index_of'.
+ // * See: `fast_last_index_of', `reverse_index_of', `index_of'.
(
reverse_index_of element start upper
)
@@ -452,7 +449,7 @@ Section Public
// Give the index of the first occurrence of `element' using basic `='
// for comparison. Answer `upper + 1' when `element' is not inside.
//
- // See also `first_index_of', `last_index_of', `fast_last_index_of'.
+ // * See: `first_index_of', `last_index_of', `fast_last_index_of'.
(
deferred;
0
@@ -466,7 +463,7 @@ Section Public
// of `element' at or after `start_index'. Answer `upper + 1' when `element'
// when the search fail.
//
- // See also `index_of', `fast_reverse_index_of', `fast_first_index_of'.
+ // * See: `index_of', `fast_reverse_index_of', `fast_first_index_of'.
(
deferred;
0
@@ -482,7 +479,7 @@ Section Public
// direction, which means from the `start_index' down to the `lower'
// index . Answer `lower -1' when the search fail.
//
- // See also `reverse_index_of', `fast_index_of', `fast_last_index_of'.
+ // * See: `reverse_index_of', `fast_index_of', `fast_last_index_of'.
[
-? { valid_index start_index };
]
@@ -501,7 +498,7 @@ Section Public
// which means from the `upper' down to the `lower' index . Answer `lower -1'
// when the search fail.
//
- // See also `fast_reverse_index_of', `last_index_of'.
+ // * See: `fast_reverse_index_of', `last_index_of'.
(
fast_reverse_index_of element start upper
)
@@ -518,7 +515,7 @@ Section Public
// items?
// The basic `=' is used for comparison of items.
//
- // See also `is_equal_map', `same_items'.
+ // * See: `is_equal_map', `same_items'.
(
deferred;
FALSE
@@ -532,7 +529,7 @@ Section Public
// items?
// Feature `==' is used for comparison of items.
//
- // See also `==', `same_items'.
+ // * See: `==', `same_items'.
(
deferred;
FALSE
@@ -545,7 +542,7 @@ Section Public
// Do all items have their type's default value?
// Note: for non NULL items, the test is performed with the `is_default' predicate.
//
- // See also `clear_all'.
+ // * See: `clear_all'.
(
deferred;
FALSE
@@ -557,7 +554,7 @@ Section Public
// example this routine may yeld true with `Current' indexed in
// range [1..2] and `other' indexed in range [2..3]).
//
- // See also `is_equal_map', `is_equal'.
+ // * See: `is_equal_map', `is_equal'.
[
-? { other != NULL };
]
@@ -583,7 +580,7 @@ Section Public
- occurrences element:V :INTEGER <-
// Number of occurrences of `element' using `equal' for comparison.
//
- // See also `fast_occurrences', `index_of'.
+ // * See: `fast_occurrences', `index_of'.
(
deferred;
0
@@ -595,7 +592,7 @@ Section Public
- fast_occurrences element:V :INTEGER <-
// Number of occurrences of `element' using basic `=' for comparison.
//
- // See also `occurrences', `index_of'.
+ // * See: `occurrences', `index_of'.
(
deferred;
0
@@ -646,7 +643,7 @@ Section Public
- do_all action:{V; } <-
// Apply `action' to every item of `Self'.
//
- // See also `for_all', `exists'.
+ // * See: `for_all', `exists'.
(
lower.to upper do { i:INTEGER;
action.value (item i);
@@ -691,7 +688,7 @@ Section Public
- for_all test:{V; BOOLEAN} :BOOLEAN <-
// Do all items satisfy `test'?
//
- // See also `do_all', `exists'.
+ // * See: `do_all', `exists'.
( + i:INTEGER;
+ result:BOOLEAN;
@@ -707,7 +704,7 @@ Section Public
- exists test:{V; BOOLEAN} :BOOLEAN <-
// Does at least one item satisfy `test'?
//
- // See also `do_all', `for_all'.
+ // * See: `do_all', `for_all'.
( + i:INTEGER;
+ result:BOOLEAN;
@@ -724,7 +721,8 @@ Section Public
//
- filter test:{V; BOOLEAN} in other:SELF <-
- // Filter all element which `test' element is true
+ // Filter all element which `test' element is true and put the result in `other'
+ // * Require : `other' not null
[
-? { other != NULL };
]
@@ -739,6 +737,7 @@ Section Public
);
- filter test:{V; BOOLEAN} : SELF <-
+ // Filter all element which `test' element is true
( + result:SELF;
result := SELF.create 0;
filter test in result;
@@ -746,6 +745,7 @@ Section Public
);
- filter_first test:{V; BOOLEAN} :V <-
+ // Filter first element which `test' element is true
( + result,elt:V;
+ is_end:BOOLEAN;
+ j:INTEGER;
@@ -763,8 +763,8 @@ Section Public
);
- fold_left function:{(V,V);} with element:V :V <-
+ // fold left with function `function' beginning with `element'
( + result:V;
-
result := element;
lower.to upper do { j:INTEGER;
result := function.value (result,item j);
@@ -773,6 +773,7 @@ Section Public
);
- fold_right function:{(V,V);} with element:V :V <-
+ // fold left with function `function' beginning with `element'
( + result:V;
result := element;
@@ -783,6 +784,7 @@ Section Public
);
- merge other:SELF with test:{(V,V); BOOLEAN} :SELF<-
+ // Return the intersection between `Self' and `other' according to `test' function
( + result:SELF;
+ elt:V;
@@ -842,7 +844,7 @@ Section Public
// Replace all occurrences of the element `old_value' by `new_value'
// using `equal' for comparison.
//
- // See also `fast_replace_all', `move'.
+ // * See: `fast_replace_all', `move'.
(
deferred;
)
@@ -855,7 +857,7 @@ Section Public
// Replace all occurrences of the element `old_value' by `new_value'
// using operator `=' for comparison.
//
- // See also `replace_all', `move'.
+ // * See: `replace_all', `move'.
(
deferred;
)
@@ -868,8 +870,7 @@ Section Public
// Move range `lower_index' .. `upper_index' by `distance'
// positions. Negative distance moves towards lower indices.
// Free places get default values.
- //
- // See also `slice', `replace_all'.
+ // * See: `slice', `replace_all'.
[
-? { lower_index <= upper_index };
-? { valid_index lower_index };
@@ -901,8 +902,13 @@ Section Public
// New collection consisting of items at indexes in [`min'..`max'].
// Result has the same dynamic type as `Current'.
// The `lower' index of the `Result' is the same as `lower'.
- //
- // See also `from_collection', `move', `replace_all'.
+ // * See: `from_collection', `move', `replace_all'.
+ // * require: `lower' inferior or equal to `min'
+ // * require: `max' inferior or equal to `upper'
+ // * require: `min' inferior or equal to `max' + 1
+ // * ensure: `Self' is same dynamic type of Result
+ // * ensure: Result size is equal to `max' - `min' + 1
+ // * ensure: Result first element index is same as `Self' first element index
[
-? { lower <= min };
-? { max <= upper };
--
Lisaac compiler
More information about the Lisaac-commits
mailing list