Index handler: Difference between revisions
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
== Representation invariant == | == Representation invariant == | ||
This abstract data structure is [[Genericity|generic]] and parameterized by | This abstract data structure is [[Genericity|generic]] and parameterized by some value type <math>\mathcal{V}</math>. An object of an implementation of this abstract data structure is repesented by: | ||
An object of an implementation of this abstract data structure is repesented by: | # A positive integral number <math>N</math>. | ||
# positive integral number <math>N</math> | # A subset <math>I</math> of <math>\{1,\ldots,N\}</math>, the '''currently used indexes'''. | ||
# A mapping <math>I\rightarrow\mathcal{V}</math>. | |||
'''Remark:''' restricted type of [[Sets and sequences#Maps|map]]. | '''Remark:''' This abstact data structure may be viewed as a specific, quite restricted type of [[Sets and sequences#Maps|map]]. | ||
== Method == | == Method == |
Revision as of 13:49, 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
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].
Method
Name: release index