home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / man / array2.tex < prev    next >
Encoding:
Text File  |  1991-11-15  |  1.5 KB  |  60 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf 3.2 Two Dimensional Arrays (array2)}
  4.  
  5. An instance $A$ of the data type $array2$ is a mapping from a set of pairs 
  6. $I = [a..b] \times [c..d]$, called the index set of $A$, to a set of 
  7. variables of a data type $E$, called the element type of $A$, for two fixed 
  8. intervals of integers $[a..b]$ and $[b..c]$.  $A(i,j)$ is called the element
  9. at position $(i,j)$. 
  10.  
  11.  
  12. {\bf 1. Declaration of a two dimensional array type}
  13.  
  14.  
  15. \decl array2 E 
  16.  
  17. introduces a new data type with name \name\ consisting of all two-dimensional
  18. arrays with element type $E$.
  19.  
  20.  
  21.  
  22. \bigskip
  23. {\bf 2. Creation of a two-dimensional array }
  24.  
  25.  
  26. \create A (a,b,c,d)
  27.  
  28. creates an instance \var\ of type \name\ with index set $[a..b]\times [c..d]$.
  29.  
  30.  
  31. \bigskip
  32. {\bf 3. Operations on a two-dimensional array A}
  33. \cleartabs
  34. \+&\hskip 1.5truecm &\hskip 6truecm &\cr
  35. \+\opf E\&  {int\ i,\ int\ j}           
  36.                             {returns $A(i,j)$. }
  37. \+\nop                      {\precond $a\le i\le b$ and $c\le j\le d$. }
  38. \smallskip
  39. \+\op  int  low1  {}        
  40.                             {returns $a$}
  41. \smallskip
  42. \+\op  int  high1 {}        
  43.                             {returns $b$}
  44. \smallskip
  45. \+\op  int  low2  {}        
  46.                             {returns $c$}
  47. \smallskip
  48. \+\op  int  high2 {}        
  49.                             {returns $d$}
  50. \smallskip
  51.  
  52.  
  53. \bigskip
  54. {\bf 4. Implementation}
  55.  
  56. Two dimensional arrays are implemented by \CC vectors. All operations
  57. take time $O(1)$, the space requirement is $O(|I|)$.
  58.  
  59.  
  60.