Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

ccp4_array.h File Reference

#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Compounds

struct  ccp4array_base_

Defines

#define ccp4array_new(v)   ccp4array_new_((ccp4_ptr*)(&v))
#define ccp4array_new_size(v, s)   ccp4array_new_size_((ccp4_ptr*)(&v),s,sizeof(*v))
#define ccp4array_resize(v, s)   ccp4array_resize_((ccp4_ptr*)(&v),s,sizeof(*v))
#define ccp4array_reserve(v, s)   ccp4array_reserve_((ccp4_ptr*)(&v),s,sizeof(*v))
#define ccp4array_append(v, d)   ccp4array_append_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),sizeof(*v))
#define ccp4array_append_n(v, d, n)   ccp4array_append_n_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),n,sizeof(*v))
#define ccp4array_append_list(v, l, n)   ccp4array_append_list_((ccp4_ptr*)(&v),(ccp4_constptr)l,n,sizeof(*v))
#define ccp4array_insert(v, i, d)   ccp4array_insert_((ccp4_ptr*)(&v),i,(ccp4_constptr)(&d),sizeof(*v))
#define ccp4array_delete_ordered(v, i)   ccp4array_delete_ordered_((ccp4_ptr*)(&v),i,sizeof(*v))
#define ccp4array_delete(v, i)   ccp4array_delete_((ccp4_ptr*)(&v),i,sizeof(*v))
#define ccp4array_delete_last(v)   ccp4array_delete_last_((ccp4_ptr*)(&v),sizeof(*v))
#define ccp4array_size(v)   ccp4array_size_((ccp4_constptr*)(&v))
#define ccp4array_free(v)   ccp4array_free_((ccp4_ptr*)(&v))

Typedefs

typedef const void * ccp4_constptr
typedef char * ccp4_byteptr
typedef void * ccp4_ptr
typedef ccp4array_base_ ccp4array_base

Functions

ccp4_ptr ccp4array_new_ (ccp4_ptr *p)
ccp4_ptr ccp4array_new_size_ (ccp4_ptr *p, const int size, const size_t reclen)
void ccp4array_resize_ (ccp4_ptr *p, const int size, const size_t reclen)
void ccp4array_reserve_ (ccp4_ptr *p, const int size, const size_t reclen)
void ccp4array_append_ (ccp4_ptr *p, ccp4_constptr data, const size_t reclen)
void ccp4array_append_n_ (ccp4_ptr *p, ccp4_constptr data, const int n, const size_t reclen)
void ccp4array_append_list_ (ccp4_ptr *p, ccp4_constptr data, const int n, const size_t reclen)
void ccp4array_insert_ (ccp4_ptr *p, const int i, ccp4_constptr data, const size_t reclen)
void ccp4array_delete_ordered_ (ccp4_ptr *p, const int i, const size_t reclen)
void ccp4array_delete_ (ccp4_ptr *p, const int i, const size_t reclen)
void ccp4array_delete_last_ (ccp4_ptr *p, const size_t reclen)
int ccp4array_size_ (ccp4_constptr *p)
void ccp4array_free_ (ccp4_ptr *p)


Detailed Description

header file for resizable array implementation. Kevin Cowtan


Define Documentation

#define ccp4array_append v,
     ccp4array_append_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),sizeof(*v))
 

Macro to append an element to an array. This increments the size. Memory allocation only takes place if the new size is greater than the capacity.

Parameters:
v  The array pointer
d  The new element (may not be a literal)

#define ccp4array_append_list v,
l,
     ccp4array_append_list_((ccp4_ptr*)(&v),(ccp4_constptr)l,n,sizeof(*v))
 

Macro to append n elements from another list to an array. This increment the size by n. Memory allocation only takes place if the new size is greater than the capacity.

Parameters:
v  The array pointer
l  Pointer to the list
n  The number of copies to append

#define ccp4array_append_n v,
d,
     ccp4array_append_n_((ccp4_ptr*)(&v),(ccp4_constptr)(&d),n,sizeof(*v))
 

Macro to append n copies of an element to an array. This increments the size by n. Memory allocation only takes place if the new size is greater than the capacity.

Parameters:
v  The array pointer
d  The new element (may not be a literal)
n  The number of copies to append

#define ccp4array_delete v,
     ccp4array_delete_((ccp4_ptr*)(&v),i,sizeof(*v))
 

Macro to delete element[i] of an array without preserving order. The last element is moved into the gap, and the size is decremented.

Parameters:
v  The array pointer
i  The element to be deleted

#define ccp4array_delete_last      ccp4array_delete_last_((ccp4_ptr*)(&v),sizeof(*v))
 

Macro to delete the last element of an array. This decrements the size.

Parameters:
v  The array pointer

#define ccp4array_delete_ordered v,
     ccp4array_delete_ordered_((ccp4_ptr*)(&v),i,sizeof(*v))
 

Macro to delete element[i] of an array, preserving order. This decrements the size. All subsequent elements are moved down. As a result this method is slow.

Parameters:
v  The array pointer
i  The element to be deleted

#define ccp4array_free      ccp4array_free_((ccp4_ptr*)(&v))
 

Macro free the array. All memory, including the header, is freed.

Parameters:
v  The array pointer

#define ccp4array_insert v,
i,
     ccp4array_insert_((ccp4_ptr*)(&v),i,(ccp4_constptr)(&d),sizeof(*v))
 

Macro to insert an element before the element[i] of an array. This increments the size. All subsequent elements are moved up. As a result this method is slow.

Parameters:
v  The array pointer
d  The new element (may not be a literal)
i  The element before which the insertion is to be made.

#define ccp4array_new      ccp4array_new_((ccp4_ptr*)(&v))
 

Macro to allocate a new array. The array is allocated with a size and capacity of 0

Parameters:
v  The array pointer
Returns:
The new array pointer (redundent)

#define ccp4array_new_size v,
     ccp4array_new_size_((ccp4_ptr*)(&v),s,sizeof(*v))
 

Macro to allocate a new array with non-zero size. The array is allocated with a size of s and capacity of at least s

Parameters:
v  The array pointer
s  The new size
Returns:
The new array pointer (redundent)

#define ccp4array_reserve v,
     ccp4array_reserve_((ccp4_ptr*)(&v),s,sizeof(*v))
 

Macro to reserve space for an array. This forces a memory reallocation. The size of the array is unchanged, unless the new capacity is less than the current size, in which case the size is set to the new capacity. Unlike resize, the new allocation will be exactly the size of the array.

Parameters:
v  The array pointer
s  The new capacity

#define ccp4array_resize v,
     ccp4array_resize_((ccp4_ptr*)(&v),s,sizeof(*v))
 

Macro to resize an array. This changes the size. Memory allocation only takes place if the new size is greater than the capacity. If that occurs, the new capacity will be slightly greater than the requested size, to allow room for expansion.

Parameters:
v  The array pointer
s  The new size

#define ccp4array_size      ccp4array_size_((ccp4_constptr*)(&v))
 

Macro to return the size of the array.

Parameters:
v  The array pointer
Returns:
The size (int)


Typedef Documentation

typedef char* ccp4_byteptr
 

byte pointer type

typedef const void* ccp4_constptr
 

constant pointer type

typedef void* ccp4_ptr
 

pointer type

typedef struct ccp4array_base_ ccp4array_base
 

struct definition for the array pre-header


Function Documentation

void ccp4array_append_ ccp4_ptr   p,
ccp4_constptr    data,
const size_t    reclen
 

See macro ccp4array_append

void ccp4array_append_list_ ccp4_ptr   p,
ccp4_constptr    data,
const int    n,
const size_t    reclen
 

See macro ccp4array_append_list

void ccp4array_append_n_ ccp4_ptr   p,
ccp4_constptr    data,
const int    n,
const size_t    reclen
 

See macro ccp4array_append_n

void ccp4array_delete_ ccp4_ptr   p,
const int    i,
const size_t    reclen
 

See macro ccp4array_delete

void ccp4array_delete_last_ ccp4_ptr   p,
const size_t    reclen
 

See macro ccp4array_delete_last

void ccp4array_delete_ordered_ ccp4_ptr   p,
const int    i,
const size_t    reclen
 

See macro ccp4array_delete_ordered

void ccp4array_free_ ccp4_ptr   p
 

See macro ccp4array_free

void ccp4array_insert_ ccp4_ptr   p,
const int    i,
ccp4_constptr    data,
const size_t    reclen
 

See macro ccp4array_insert

ccp4_ptr ccp4array_new_ ccp4_ptr   p
 

See macro ccp4array_new

ccp4_ptr ccp4array_new_size_ ccp4_ptr   p,
const int    size,
const size_t    reclen
 

See macro ccp4array_new_size

void ccp4array_reserve_ ccp4_ptr   p,
const int    size,
const size_t    reclen
 

See macro ccp4array_reserve

void ccp4array_resize_ ccp4_ptr   p,
const int    size,
const size_t    reclen
 

See macro ccp4array_resize

int ccp4array_size_ ccp4_constptr   p
 

See macro ccp4array_size