Difference between revisions of "Lib/storage"
(translation wanted) |
(→Sets: typos) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | [[Category:Book]] |
||
{{TranslationWanted}} |
{{TranslationWanted}} |
||
+ | [[Category:Book]] |
||
+ | |||
+ | This library is one of the most essential ones of SmartEiffel. It is generally used along with [[lib/abilities]] because some classes require specific properties about objects they can contain. Most of the storage classes are also [[library_class:TRAVERSABLE|<tt>TRAVERSABLE</tt>]], and also supply objects of the [[library_class:ITERATOR|<tt>ITERATOR</tt>]] kind (see the [[lib/iterator]] library). |
||
+ | |||
+ | The point here is to store objects. This implies not only to "remember" them, but also to "retrieve" them, of course. But everything is based on the ''way'' to retrieve a stored object. |
||
+ | |||
+ | == Collections == |
||
+ | [[library_class:COLLECTION|Collections]] are classes that allow to store objects and recover them by using integers. There are the two most known implementations, that are arrays (contiguous storage of elements) and linked lists (storage of elements by references to other elements). |
||
+ | |||
+ | The most useful classes are : |
||
+ | * [[library_class:ARRAY|<tt>ARRAY</tt>]], the well-known array |
||
+ | * [[library_class:RING_ARRAY|<tt>RING_ARRAY</tt>]], an array whose implementation is optimized for extensions at both ends |
||
+ | * [[library_class:FAST_ARRAY|<tt>FAST_ARRAY</tt>]], an array whose lower bound is 0 |
||
+ | * [[library_class:LINKED_LIST|<tt>LINKED_LIST</tt>]] and [[library_class:TWO_WAY_LINKED_LIST|<tt>TWO_WAY_LINKED_LIST</tt>]] are linked lists |
||
+ | |||
+ | There are also [[library_class:COLLECTION2|two-]] and [[library_class:COLLECTION3|three-]]dimensionnal collections that allow to manipulate object matrices |
||
+ | |||
+ | == Dictionaries == |
||
+ | [[library_class:DICTIONARY|Dictionaries]] are classes that allow to store key-value couples. Thus, a value is available with its key. |
||
+ | |||
+ | One can say that collections are equivalent to dictionaries whose keys are integers, but the case of collections is kept because it is very frequent. |
||
+ | |||
+ | There are several dictionary implementations, that use different properties of the keys to accelerate access to the elements without having to look through the whole dictionary. |
||
+ | |||
+ | * If the keys are [[library_class:HASHABLE|<tt>HASHABLE</tt>]], one can use the [[library_class:HASHED_DICTIONARY|<tt>HASHED_DICTIONARY</tt>]] class that uses the <tt>hash_code</tt> of the keys. |
||
+ | * If the keys are [[library_class:COMPARABLE|<tt>COMPARABLE</tt>]], one can use the [[library_class:AVL_DICTIONARY|<tt>AVL_DICTIONARY</tt>]] class that uses a balanced binary tree. |
||
+ | * There is no implementation if the keys have none of these two properties. |
||
+ | |||
+ | One will notice the [[library_class:BIJECTIVE_DICTIONARY|bijective dictionaries]] whose elements are all unique. One can also define an inverted bijective dictionary ''(planned class for the version 2.3)''. |
||
+ | |||
+ | == Sets == |
||
+ | [[library_class:SET|Sets]] are classes that allow to store elements in a unique manner. The goal is not necessarily to retrieve them by a key, but to know how to ''look through'' the set of elements. |
||
+ | |||
+ | As with dictionaries, there are two kinds of sets in accordance with the properties of the elements. |
||
+ | |||
+ | * If the elements are [[library_class:HASHABLE|<tt>HASHABLE</tt>]], one can use the [[library_class:HASHED_SET|<tt>HASHED_SET<tt>]] classe that uses the <tt>hash_code</tt> of the elements. |
||
+ | * If the elements are [[library_class:COMPARABLE|<tt>COMPARABLE</tt>]], one can use the [[library_class:AVL_SET|<tt>AVL_SET</tt>]] class that uses a balanced binary tree. |
||
+ | * There is no implementation if the elements have none of these two properties. |
||
+ | |||
+ | == Multi-sets == |
||
+ | <tt>MULTI_SET</tt>s are not implemented. |
||
+ | |||
+ | == Queues and stacks == |
||
+ | The [[library_class:QUEUE|<tt>QUEUE</tt>]] class implements queues of objects. |
||
+ | |||
+ | The [[library_class:STACK|<tt>STACK</tt>]] class implements stacks of objects. |
||
+ | |||
+ | == Repositories == |
||
+ | [[library_class:REPOSITORY|Repositories]] allow to store objects so as to retrieve them later. The point here is to ''serialize'' objects. This is useful, for example, to store objects on the hard drive (by using [[lib/io]]), or to transmit them on the network (by using [[lib/net]]), etc. |
||
+ | |||
+ | These repositories behave like dictionaries whose keys are [[library_class:STRING|strings]] and values are [[library_class:STORABLE|<tt>STORABLE</tt>]]. Their interface is similar to the one of the dictionaries, with additional features to load objects (<tt>update</tt>) and store them (<tt>commit</tt>). |
||
+ | |||
+ | There is a single implementation of repository : the [[library_class:XML_REPOSITORY|<tt>XML_REPOSITORY</tt>]] class that transforms objects into an XML stream (by using [[lib/xml]]). |
Revision as of 08:55, 13 February 2006
This library is one of the most essential ones of SmartEiffel. It is generally used along with lib/abilities because some classes require specific properties about objects they can contain. Most of the storage classes are also TRAVERSABLE, and also supply objects of the ITERATOR kind (see the lib/iterator library).
The point here is to store objects. This implies not only to "remember" them, but also to "retrieve" them, of course. But everything is based on the way to retrieve a stored object.
Collections
Collections are classes that allow to store objects and recover them by using integers. There are the two most known implementations, that are arrays (contiguous storage of elements) and linked lists (storage of elements by references to other elements).
The most useful classes are :
- ARRAY, the well-known array
- RING_ARRAY, an array whose implementation is optimized for extensions at both ends
- FAST_ARRAY, an array whose lower bound is 0
- LINKED_LIST and TWO_WAY_LINKED_LIST are linked lists
There are also two- and three-dimensionnal collections that allow to manipulate object matrices
Dictionaries
Dictionaries are classes that allow to store key-value couples. Thus, a value is available with its key.
One can say that collections are equivalent to dictionaries whose keys are integers, but the case of collections is kept because it is very frequent.
There are several dictionary implementations, that use different properties of the keys to accelerate access to the elements without having to look through the whole dictionary.
- If the keys are HASHABLE, one can use the HASHED_DICTIONARY class that uses the hash_code of the keys.
- If the keys are COMPARABLE, one can use the AVL_DICTIONARY class that uses a balanced binary tree.
- There is no implementation if the keys have none of these two properties.
One will notice the bijective dictionaries whose elements are all unique. One can also define an inverted bijective dictionary (planned class for the version 2.3).
Sets
Sets are classes that allow to store elements in a unique manner. The goal is not necessarily to retrieve them by a key, but to know how to look through the set of elements.
As with dictionaries, there are two kinds of sets in accordance with the properties of the elements.
- If the elements are HASHABLE, one can use the HASHED_SET classe that uses the hash_code of the elements.
- If the elements are COMPARABLE, one can use the AVL_SET class that uses a balanced binary tree.
- There is no implementation if the elements have none of these two properties.
Multi-sets
MULTI_SETs are not implemented.
Queues and stacks
The QUEUE class implements queues of objects.
The STACK class implements stacks of objects.
Repositories
Repositories allow to store objects so as to retrieve them later. The point here is to serialize objects. This is useful, for example, to store objects on the hard drive (by using lib/io), or to transmit them on the network (by using lib/net), etc.
These repositories behave like dictionaries whose keys are strings and values are STORABLE. Their interface is similar to the one of the dictionaries, with additional features to load objects (update) and store them (commit).
There is a single implementation of repository : the XML_REPOSITORY class that transforms objects into an XML stream (by using lib/xml).