/** * int-vector.h * "Vectors" - Slightly safer arrays. */ // +-----------+------------------------------------------------------ // | Functions | // +-----------+ /** * Procedure: * iv_new * Parameters: * size, an integer * Purpose: * Create a new vector of integers of size size. * Produces: * iv, a vector of integers * Preconditions: * size > 0 * Postconditions: * [No additional] */ struct int_vector *iv_new (int size); /** * Procedure: * iv_get * Parameters: * iv, a vector of integers * i, an integer * Purpose: * Get the ith element of iv. * Produces: * v, a value * Preconditions: * [No additional] * Postconditions: * If 0 <= i < iv_size (iv), then v is the last value given by * iv_set (iv, i, v). Otherwise, an error message is printed and * v is INT_MIN. */ int iv_get (struct int_vector *iv, int i); /** * Procedure: * iv_set * Parameters: * iv, a vector of integers * i, an integer * v, an integer * Purpose: * Set the ith element of iv to v. * Produces: * [Nothing; Called for the side effect] * Preconditions: * No additional * Postconditions: * If 0 <= i < iv_size(iv), then subsequent calls to iv_get(iv,i) * will return v. Otherwise, iv_set has no effect (other than * the generation of an error message). */ void iv_set (struct int_vector *iv, int i, int v); /** * Procedure: * iv_size * Parameters: * iv, a vector of integers * Purpose: * Get the size of the vector * Produces: * size, an integer */ int iv_size (struct int_vector *iv);