home *** CD-ROM | disk | FTP | other *** search
- %
- % @(#)Vector.m 1.2 10/5/87
- %
- export _VectorObject to "Builtins"
-
- const _VectorObject ==
- immutable object _VectorObject
- export of
- function of [ElementType : AbstractType] -> [result : NVT]
- where
- NVT == immutable type NVT
- operation create [Integer] -> [NV]
- function getSignature -> [Signature]
- end NVT
- NV == type NV
- function getElement [Integer] -> [ElementType]
- % get the element indexed by index, failing if index
- % out of range.
- operation setElement [Integer, ElementType]
- % set the element, failing if index out of range
- function upperbound -> [Integer]
- % return the highest valid index, ub.
- function lowerbound -> [Integer]
- % return the lowest valid index, always 1.
- function getSlice [Integer, Integer] -> [NV]
- % See implementation comment
- end NV
- ElementType *> type T end T
- end where
- result <-
- immutable object aNVT
- export create, getSignature
-
- function getSignature -> [result : Signature]
- result <- NV
- end getSignature
-
- operation create[length : Integer] -> [result : NV]
- result <-
- object aNV
- export getElement, setElement, upperbound, lowerbound,
- getSlice
-
- function getElement [index : Integer] -> [result : ElementType]
- % get the element indexed by index, failing if index
- % out of range.
- primitive 012 [result] <- [index]
- end getElement
- operation setElement [index : Integer, e : ElementType]
- % set the element, failing if index out of range
- primitive 112 [] <- [index, e]
- end setElement
- function upperbound -> [r : Integer]
- % return the highest valid index, ub.
- primitive 212 [r] <- []
- end upperbound
- function lowerbound -> [r : Integer]
- % return the lowest valid index, always 1.
- primitive 312 [r] <- []
- end lowerbound
- function getSlice [i1 : Integer, length : Integer] -> [r : NV]
- % return a new Vector, a, with lower bound 0, and
- % upper bound length-1, such that for 0 <= i < length:
- % self.getElement[i1+i] == a.getElement[i]
- % fail if i1 or i1+length is out of range.
- primitive 412 [r] <- [i1, length]
- end getSlice
- end aNV
- end create
- end aNVT
- end of
- end _VectorObject
-