Ilya Moiseenko | c115fba | 2011-08-01 10:53:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ccn_indexbuf.h |
| 3 | * Abstraction |
| 4 | * |
| 5 | * Created by Ilya on 7/29/11. |
| 6 | * Copyright 2011 __MyCompanyName__. All rights reserved. |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * @file ccn/indexbuf.h |
| 12 | * |
| 13 | * Expandable buffer of non-negative values. |
| 14 | * |
| 15 | * Part of the CCNx C Library. |
| 16 | * |
| 17 | * Copyright (C) 2008, 2009 Palo Alto Research Center, Inc. |
| 18 | * |
| 19 | * This library is free software; you can redistribute it and/or modify it |
| 20 | * under the terms of the GNU Lesser General Public License version 2.1 |
| 21 | * as published by the Free Software Foundation. |
| 22 | * This library is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 25 | * Lesser General Public License for more details. You should have received |
| 26 | * a copy of the GNU Lesser General Public License along with this library; |
| 27 | * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, |
| 28 | * Fifth Floor, Boston, MA 02110-1301 USA. |
| 29 | */ |
| 30 | |
| 31 | #ifndef CCN_INDEXBUF_DEFINED |
| 32 | #define CCN_INDEXBUF_DEFINED |
| 33 | |
| 34 | #include <stddef.h> |
| 35 | |
| 36 | struct ccn_indexbuf { |
| 37 | size_t n; |
| 38 | size_t limit; |
| 39 | size_t *buf; |
| 40 | }; |
| 41 | |
| 42 | struct ccn_indexbuf *ccn_indexbuf_create(void); |
| 43 | void ccn_indexbuf_destroy(struct ccn_indexbuf **cbp); |
| 44 | size_t *ccn_indexbuf_reserve(struct ccn_indexbuf *c, size_t n); |
| 45 | int ccn_indexbuf_append(struct ccn_indexbuf *c, const size_t *p, size_t n); |
| 46 | int ccn_indexbuf_append_element(struct ccn_indexbuf *c, size_t v); |
| 47 | int ccn_indexbuf_member(struct ccn_indexbuf *x, size_t val); |
| 48 | void ccn_indexbuf_remove_element(struct ccn_indexbuf *x, size_t val); |
| 49 | int ccn_indexbuf_set_insert(struct ccn_indexbuf *x, size_t val); |
| 50 | int ccn_indexbuf_remove_first_match(struct ccn_indexbuf *x, size_t val); |
| 51 | void ccn_indexbuf_move_to_end(struct ccn_indexbuf *x, size_t val); |
| 52 | void ccn_indexbuf_move_to_front(struct ccn_indexbuf *x, size_t val); |
| 53 | |
| 54 | #endif |