Annotation of embedaddon/iftop/vector.h, revision 1.1
1.1 ! misho 1: /*
! 2: * vector.h:
! 3: * simple vectors
! 4: *
! 5: * Copyright (c) 2001 Chris Lightfoot. All rights reserved.
! 6: *
! 7: * $Id: vector.h,v 1.1 2003/10/19 06:44:33 pdw Exp $
! 8: *
! 9: */
! 10:
! 11: #ifndef __VECTOR_H_ /* include guard */
! 12: #define __VECTOR_H_
! 13:
! 14: typedef union _item {
! 15: void *v;
! 16: long l;
! 17: } item;
! 18:
! 19: #define _inline inline
! 20:
! 21: static _inline item item_long(const long l) { item u; u.l = l; return u; }
! 22: static _inline item item_ptr(void *const v) { item u; u.v = v; return u; }
! 23:
! 24: typedef struct _vector{
! 25: item *ary;
! 26: size_t n, n_used;
! 27: } *vector;
! 28:
! 29: vector vector_new(void);
! 30: void vector_delete(vector);
! 31: void vector_delete_free(vector);
! 32:
! 33: void vector_push_back(vector, const item);
! 34: void vector_pop_back(vector);
! 35: item vector_back(const vector);
! 36:
! 37: item *vector_remove(vector, item *t);
! 38:
! 39: void vector_reallocate(vector, const size_t n);
! 40:
! 41: /* A macro to iterate over a vector */
! 42: #define vector_iterate(_v, _t) for ((_t) = (_v)->ary; (_t) < (_v)->ary + (_v)->n_used; ++(_t))
! 43:
! 44: #endif /* __VECTOR_H_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>