Tools.h++ Manual

104011 Tandem Computers Incorporated 22-125
22
Program output:
100
300
500
5000
Public constructors
RWTValVirtualArray<T>(long size, RWVirtualPageHeap* heap);
Construct a vector of length size. The pages for the vector will be allocated
from the page heap given by heap which can be of any type.
RWTValVirtualArray<T>(const RWTValVirtualArray<T>& v);
Constructs a vector as a copy of
v
. The resultant vector will use the same heap
and have the same length as
v
. The actual copy will not be made until a write,
minimizing the amount of heap allocations and copying that must be done.
RWTValVirtualArray<T>(const RWTVirtualSlice<T>& sl);
Constructs a vector from a slice of another vector. The resultant vector will use
the same heap as the vector whose slice is being taken. Its length will be given
by the length of the slice. The copy will be made immediately.
Public destructor
~RWTValVirtualArray<T>();
Releases all pages allocated by the vector.
Public operators
RWTValVirtualArray&
operator=(const RWTValVirtualArray<T>& v)
;
Sets self to a copy of
v
. The resultant vector will use the same heap and have
the same length as
v
. The actual copy will not be made until a write,
minimizing the amount of heap allocations and copying that must be done.
cout << vec1[300] << endl; // Prints "300"
RWTValVirtualArray<EsatzInt> vec2 = vec.slice(5000L, 500L);
cout << vec2.length() << endl; // Prints "500"
cout << vec2[0] << endl; // Prints "5000";
return 0;
}
Code Example 22-8 (Continued)