zmaxheap.h
Go to the documentation of this file.
1 /* Copyright (C) 2013-2016, The Regents of The University of Michigan.
2 All rights reserved.
3 
4 This software was developed in the APRIL Robotics Lab under the
5 direction of Edwin Olson, ebolson@umich.edu. This software may be
6 available under alternative licensing terms; contact the address above.
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10 
11 1. Redistributions of source code must retain the above copyright notice, this
12  list of conditions and the following disclaimer.
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 The views and conclusions contained in the software and documentation are those
29 of the authors and should not be interpreted as representing official policies,
30 either expressed or implied, of the Regents of The University of Michigan.
31 */
32 
33 #ifndef _ZMAXHEAP_H
34 #define _ZMAXHEAP_H
35 
36 #include <stdio.h>
37 
38 typedef struct zmaxheap zmaxheap_t;
39 
43  int in, out;
44 };
45 
46 zmaxheap_t *zmaxheap_create(size_t el_sz);
47 
48 void zmaxheap_vmap(zmaxheap_t *heap, void (*f)());
49 
50 void zmaxheap_destroy(zmaxheap_t *heap);
51 
52 void zmaxheap_add(zmaxheap_t *heap, void *p, float v);
53 
54 int zmaxheap_size(zmaxheap_t *heap);
55 
56 // returns 0 if the heap is empty, so you can do
57 // while (zmaxheap_remove_max(...)) { }
58 int zmaxheap_remove_max(zmaxheap_t *heap, void *p, float *v);
59 
61 // This is a peculiar iterator intended to support very specific (and
62 // unusual) applications, and the heap is not necessarily in a valid
63 // state until zmaxheap_iterator_finish is called. Consequently, do
64 // not call any other methods on the heap while iterating through.
65 
66 // you must provide your own storage for the iterator, and pass in a
67 // pointer.
69 
70 // Traverses the heap in top-down/left-right order. makes a copy of
71 // the content into memory (p) that you provide.
72 int zmaxheap_iterator_next(zmaxheap_iterator_t *it, void *p, float *v);
73 
74 // will set p to be a pointer to the heap's internal copy of the dfata.
75 int zmaxheap_iterator_next_volatile(zmaxheap_iterator_t *it, void *p, float *v);
76 
77 // remove the current element.
79 
80 // call after all iterator operations are done. After calling this,
81 // the iterator should no longer be used, but the heap methods can be.
83 
84 #endif
void zmaxheap_iterator_finish(zmaxheap_iterator_t *it)
Definition: zmaxheap.c:342
int zmaxheap_iterator_next(zmaxheap_iterator_t *it, void *p, float *v)
Definition: zmaxheap.c:261
void zmaxheap_destroy(zmaxheap_t *heap)
Definition: zmaxheap.c:105
void zmaxheap_vmap(zmaxheap_t *heap, void(*f)())
Definition: zmaxheap.c:166
void zmaxheap_add(zmaxheap_t *heap, void *p, float v)
Definition: zmaxheap.c:139
int zmaxheap_iterator_next_volatile(zmaxheap_iterator_t *it, void *p, float *v)
Definition: zmaxheap.c:281
int zmaxheap_remove_max(zmaxheap_t *heap, void *p, float *v)
Definition: zmaxheap.c:248
void zmaxheap_iterator_remove(zmaxheap_iterator_t *it)
Definition: zmaxheap.c:301
zmaxheap_t * heap
Definition: zmaxheap.h:42
int zmaxheap_size(zmaxheap_t *heap)
Definition: zmaxheap.c:113
void zmaxheap_iterator_init(zmaxheap_t *heap, zmaxheap_iterator_t *it)
Definition: zmaxheap.c:253
zmaxheap_t * zmaxheap_create(size_t el_sz)
Definition: zmaxheap.c:92


apriltags2
Author(s): Danylo Malyuta
autogenerated on Fri Oct 19 2018 04:02:32