diff options
| author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-03 01:05:09 -0400 | 
|---|---|---|
| committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-04 23:10:28 -0400 | 
| commit | 72cb2e77024970509ff403670f9e4245bcefebd6 (patch) | |
| tree | e5209cd49f7f005884561bb834b37f7175b67363 /collections/vector/vector.c | |
| parent | b253b373ea74539a0f29a88ac2be728aa8158d2a (diff) | |
Add swap function to vectors
Diffstat (limited to 'collections/vector/vector.c')
| -rw-r--r-- | collections/vector/vector.c | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/collections/vector/vector.c b/collections/vector/vector.c index 5cb56ef..a7e0845 100644 --- a/collections/vector/vector.c +++ b/collections/vector/vector.c @@ -174,6 +174,22 @@ int index;  	return root->base[index];  } +void vec_swap(root, i, j) +vec *root; +int i,j; +{ +	void *tmp; + +	if (!root || i >= root->end || i < 0 || j >= root->end || j < 0) +		return; + +	tmp = root->base[i]; +	root->base[i] = root->base[j]; +	root->base[j] = tmp; + +	return; +} +  void vec_clear(root)  vec *root;  {  | 
