1 /* -*- mode: C -*-  */
2 /*
3    IGraph library.
4    Copyright (C) 2009-2020  The igraph development team
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston, MA
19    02110-1301 USA
20 
21 */
22 
23 #ifndef IGRAPH_CORE_BUCKETS_H
24 #define IGRAPH_CORE_BUCKETS_H
25 
26 #undef __BEGIN_DECLS
27 #undef __END_DECLS
28 #ifdef __cplusplus
29     #define __BEGIN_DECLS extern "C" {
30     #define __END_DECLS }
31 #else
32     #define __BEGIN_DECLS /* empty */
33     #define __END_DECLS /* empty */
34 #endif
35 
36 #include "igraph_types.h"
37 #include "igraph_vector.h"
38 
39 __BEGIN_DECLS
40 
41 /* Buckets, needed for the maximum flow algorithm */
42 
43 typedef struct igraph_buckets_t {
44     igraph_vector_long_t bptr;
45     igraph_vector_long_t buckets;
46     igraph_integer_t max, no;
47 } igraph_buckets_t;
48 
49 int igraph_buckets_init(igraph_buckets_t *b, long int bsize, long int size);
50 void igraph_buckets_destroy(igraph_buckets_t *b);
51 void igraph_buckets_clear(igraph_buckets_t *b);
52 long int igraph_buckets_popmax(igraph_buckets_t *b);
53 long int igraph_buckets_pop(igraph_buckets_t *b, long int bucket);
54 igraph_bool_t igraph_buckets_empty(const igraph_buckets_t *b);
55 igraph_bool_t igraph_buckets_empty_bucket(const igraph_buckets_t *b,
56         long int bucket);
57 void igraph_buckets_add(igraph_buckets_t *b, long int bucket,
58                         long int elem);
59 
60 typedef struct igraph_dbuckets_t {
61     igraph_vector_long_t bptr;
62     igraph_vector_long_t next, prev;
63     igraph_integer_t max, no;
64 } igraph_dbuckets_t;
65 
66 int igraph_dbuckets_init(igraph_dbuckets_t *b, long int bsize, long int size);
67 void igraph_dbuckets_destroy(igraph_dbuckets_t *b);
68 void igraph_dbuckets_clear(igraph_dbuckets_t *b);
69 long int igraph_dbuckets_popmax(igraph_dbuckets_t *b);
70 long int igraph_dbuckets_pop(igraph_dbuckets_t *b, long int bucket);
71 igraph_bool_t igraph_dbuckets_empty(const igraph_dbuckets_t *b);
72 igraph_bool_t igraph_dbuckets_empty_bucket(const igraph_dbuckets_t *b,
73         long int bucket);
74 void igraph_dbuckets_add(igraph_dbuckets_t *b, long int bucket,
75                          long int elem);
76 void igraph_dbuckets_delete(igraph_dbuckets_t *b, long int bucket,
77                             long int elem);
78 
79 __END_DECLS
80 
81 #endif
82