Index handler: Difference between revisions
No edit summary |
|||
Line 11: | Line 11: | ||
'''Name:''' reserve index | '''Name:''' reserve index | ||
'''Parameter:''' A value <math>V\in\mathcal{V}</math>. | |||
'''Precondition:''' <math>|I|<N</math>. | '''Precondition:''' <math>|I|<N</math>. | ||
Line 16: | Line 18: | ||
'''Return value:''' One of the indexes not in <math>I</math>. | '''Return value:''' One of the indexes not in <math>I</math>. | ||
'''Postcondition:''' The returned index is inserted in <math>I</math>. | '''Postcondition:''' The returned index is inserted in <math>I</math> and associated with <math>V</math>. | ||
== Method == | == Method == | ||
'''Name:''' release index | '''Name:''' release index | ||
'''Parameter:''' An integral number <math>i</math>. | |||
'''Precondition:''' <math>i\in I</math> |
Revision as of 13:52, 20 October 2014
Representation invariant
This abstract data structure is generic and parameterized by some value type [math]\displaystyle{ \mathcal{V} }[/math]. An object of an implementation of this abstract data structure is repesented by:
- A positive integral number [math]\displaystyle{ N }[/math].
- A subset [math]\displaystyle{ I }[/math] of [math]\displaystyle{ \{1,\ldots,N\} }[/math], the currently used indexes.
- A mapping [math]\displaystyle{ I\rightarrow\mathcal{V} }[/math].
Remark: This abstact data structure may be viewed as a specific, quite restricted type of map.
Method
Name: reserve index
Parameter: A value [math]\displaystyle{ V\in\mathcal{V} }[/math].
Precondition: [math]\displaystyle{ |I|\lt N }[/math].
Return value: One of the indexes not in [math]\displaystyle{ I }[/math].
Postcondition: The returned index is inserted in [math]\displaystyle{ I }[/math] and associated with [math]\displaystyle{ V }[/math].
Method
Name: release index
Parameter: An integral number [math]\displaystyle{ i }[/math].
Precondition: [math]\displaystyle{ i\in I }[/math]