pcb 4.1.1
An interactive printed circuit board layout editor.

vector.c File Reference

Operations on vectors. More...

#include <assert.h>
#include <stdlib.h>
#include "global.h"
#include "vector.h"
Include dependency graph for vector.c:

Go to the source code of this file.

Data Structures

struct  vector_struct

Functions

static int __vector_is_good (vector_t *vector)
 Helper function for assertions.
vector_tvector_create ()
 Create an empty vector.
void vector_destroy (vector_t **vector)
 Destroy a vector.
int vector_is_empty (vector_t *vector)
int vector_size (vector_t *vector)
vector_element_t vector_element (vector_t *vector, int N)
vector_element_t vector_element_first (vector_t *vector)
 Return the first element of the vector.
vector_element_t vector_element_last (vector_t *vector)
 Return the last element of the vector.
void vector_append (vector_t *vector, vector_element_t data)
 Add data to end of vector.
void vector_append_many (vector_t *vector, vector_element_t data[], int count)
 Add multiple elements to end of vector.
void vector_append_vector (vector_t *vector, vector_t *other_vector)
 Add a vector of elements to the end of vector.
void vector_insert (vector_t *vector, int N, vector_element_t data)
 Add data at specified position of vector.
void vector_insert_many (vector_t *vector, int N, vector_element_t data[], int count)
 Add data at specified position of vector.
vector_tvector_duplicate (vector_t *orig)
 Copy a vector.
vector_element_t vector_remove_last (vector_t *vector)
 Return and delete the *last* element of vector.
vector_element_t vector_remove (vector_t *vector, int N)
 Return and delete data at specified position of vector.
vector_element_t vector_replace (vector_t *vector, vector_element_t data, int N)
 Replace the data at the specified position with the given data.

Detailed Description

Operations on vectors.

Author:
this file, vector.c, was written and is Copyright (c) 2001 C. Scott Ananian.

Copyright.


PCB, interactive printed circuit board design

Copyright (C) 1994,1995,1996 Thomas Nau

Copyright (C) 1998,1999,2000,2001 harry eaton

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Contact addresses for paper mail and Email:

harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA

haceaton@aplcomm.jhuapl.edu

Definition in file vector.c.


Function Documentation

void vector_append ( vector_t vector,
vector_element_t  data 
)

Add data to end of vector.

Definition at line 169 of file vector.c.

References vector_struct::size, and vector_insert_many().

Referenced by append(), moveable_edge(), mtspace_query_rect(), path_conflicts(), qloop(), query_one(), and RouteOne().

Here is the call graph for this function:

void vector_append_many ( vector_t vector,
vector_element_t  data[],
int  count 
)

Add multiple elements to end of vector.

Definition at line 178 of file vector.c.

References vector_struct::size, and vector_insert_many().

Referenced by vector_append_vector().

Here is the call graph for this function:

void vector_append_vector ( vector_t vector,
vector_t other_vector 
)

Add a vector of elements to the end of vector.

Definition at line 187 of file vector.c.

References vector_struct::element, vector_struct::size, and vector_append_many().

Here is the call graph for this function:

vector_t* vector_create ( )

Create an empty vector.

Definition at line 95 of file vector.c.

References __vector_is_good().

Referenced by BreakManyEdges(), mtspace_query_rect(), path_conflicts(), RouteOne(), and vector_duplicate().

Here is the call graph for this function:

void vector_destroy ( vector_t **  vector)

Destroy a vector.

Definition at line 109 of file vector.c.

References __vector_is_good().

Referenced by mtsFreeWork(), and RouteOne().

Here is the call graph for this function:

vector_t* vector_duplicate ( vector_t orig)

Copy a vector.

Definition at line 230 of file vector.c.

References __vector_is_good(), vector_struct::element, malloc(), vector_struct::max, vector_struct::size, and vector_create().

Referenced by path_conflicts().

Here is the call graph for this function:

vector_element_t vector_element ( vector_t vector,
int  N 
)

Definition at line 135 of file vector.c.

References __vector_is_good(), vector_struct::element, and N.

Referenced by __routebox_is_good(), touch_conflicts(), vector_element_first(), and vector_element_last().

Here is the call graph for this function:

vector_element_t vector_element_first ( vector_t vector)

Return the first element of the vector.

Definition at line 146 of file vector.c.

References __vector_is_good(), vector_struct::size, and vector_element().

Here is the call graph for this function:

vector_element_t vector_element_last ( vector_t vector)

Return the last element of the vector.

Definition at line 157 of file vector.c.

References __vector_is_good(), vector_struct::size, and vector_element().

Here is the call graph for this function:

void vector_insert ( vector_t vector,
int  N,
vector_element_t  data 
)

Add data at specified position of vector.

Definition at line 196 of file vector.c.

References vector_insert_many().

Here is the call graph for this function:

void vector_insert_many ( vector_t vector,
int  N,
vector_element_t  data[],
int  count 
)

Add data at specified position of vector.

Definition at line 205 of file vector.c.

References __vector_is_good(), vector_struct::element, MAX, vector_struct::max, realloc(), and vector_struct::size.

Referenced by vector_append(), vector_append_many(), and vector_insert().

Here is the call graph for this function:

int vector_is_empty ( vector_t vector)

Definition at line 121 of file vector.c.

References __vector_is_good(), and vector_struct::size.

Referenced by do_via_search(), mtsFreeWork(), mtspace_query_rect(), qloop(), and RouteOne().

Here is the call graph for this function:

vector_element_t vector_remove ( vector_t vector,
int  N 
)

Return and delete data at specified position of vector.

Definition at line 257 of file vector.c.

References __vector_is_good(), vector_struct::element, N, and vector_struct::size.

Referenced by vector_remove_last().

Here is the call graph for this function:

vector_element_t vector_remove_last ( vector_t vector)

Return and delete the *last* element of vector.

Definition at line 247 of file vector.c.

References vector_struct::size, and vector_remove().

Referenced by do_via_search(), mtsFreeWork(), qloop(), and RouteOne().

Here is the call graph for this function:

vector_element_t vector_replace ( vector_t vector,
vector_element_t  data,
int  N 
)

Replace the data at the specified position with the given data.

Returns:
the old data.

Definition at line 277 of file vector.c.

References __vector_is_good(), vector_struct::element, and N.

Here is the call graph for this function:

int vector_size ( vector_t vector)

Definition at line 128 of file vector.c.

References __vector_is_good(), and vector_struct::size.

Referenced by __routebox_is_good(), mtsBoxCount(), and touch_conflicts().

Here is the call graph for this function: