Next: Typed Lists Up: Basic Objects Previous: Collections

## Typed Vectors

All of the following methods are generated automatically for each type of vector. The instantiation of new types requires recompiling, so the process will eventually be described in the programmer's manual. However, most users should be satisfied with the types currently available: `int, char, Vertex, Graph, Edge, Attribute`.

Figure 8.9: k-sets and power sets of a set
| (vector-type size )

Creates an empty dynamic array with size C++ elements of type type. O(1)

| (vector-type->list vec )

Create a Scheme list containing the elements of vec . Note: for C++ types which have close Scheme analogs, such as `int`, the resulting list elements may be appropriately-typed Scheme objects. O(n)

| (vector-type? vec )

Return #t if vec is a vector of C++ objects of type type. O(1)

| (vector-ref vec index )

Return the element of vec at location . O(1)

| (vector-fill! vec value )

Fill all of the entries of vec with value. O(n)

| (vector-copy vec )

Create and return a new copy of vec . O(n)

| (vector-set! vec )

Assign value to vect[index]. O(1)

| (vector-length vec )

Return the length of the longest initialized segment of vec . O(n)

| (eq? vec1 vec2 veck )

Return true if all argments are the same vector. O(n)

| (eqv? vec1 vec2 veck )

Return true if all argments are vectors with the same elements. O(n)

| (< vec1 vec2 veck )

Return true if veci < vecj whenever . Ordering is lexicographic. O(n)

| (<= vec1 vec2 veck )

Return true if veci <= vecj whenever . Ordering is lexicographic. O(n)

| (> vec1 vec2 veck )

Return true if veci > vecj whenever . Ordering is lexicographic. O(n)

| (>= vec1 vec2 veck )

Return true if veci >= vecj whenever . Ordering is lexicographic. O(n)

| (vector-resize vec newsize )

Change the number of memory locations allocated to vec . O(n + newsize)

Figure 8.10: Creating and manipulating vectors

Figure 8.11: Typed vs. untyped vectors

Figure 8.12: Conversion of typed vector to Scheme list

Figure 8.13: Copying of typed vectors

Figure 8.14: Comparison of typed vectors

Next: Typed Lists Up: Basic Objects Previous: Collections