annotate CircularQueue.h @ 58:79503033cf53

merged
author Eric Wing <ewing . public |-at-| gmail . com>
date Wed, 30 May 2012 02:26:03 -0700
parents 516da6d93534
children 36644b1b940b
rev   line source
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
1 /*
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
2 CircularQueue
2
279d0427ef26 Overhaul prep for first public release.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 1
diff changeset
3 Copyright (C) 2002 Eric Wing <ewing . public @ playcontrol.net>
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
4
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
9
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
13 Library General Public License for more details.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
14
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
18 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
19
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
20
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
21 #ifndef C_CIRCULAR_QUEUE_H
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
22 #define C_CIRCULAR_QUEUE_H
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
23
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
24 /* Set up for C function definitions, even when using C++ */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
25 #ifdef __cplusplus
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
26 extern "C" {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
27 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
28
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
29 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
30 /** @cond DOXYGEN_SHOULD_IGNORE_THIS */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
31
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
32 /* Note: For Doxygen to produce clean output, you should set the
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
33 * PREDEFINED option to remove C_CIRCULAR_QUEUE_DECLSPEC, C_CIRCULAR_QUEUE_CALL, and
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
34 * the DOXYGEN_SHOULD_IGNORE_THIS blocks.
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
35 * PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 C_CIRCULAR_QUEUE_DECLSPEC= C_CIRCULAR_QUEUE_CALL=
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
36 */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
37
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
38 /** Windows needs to know explicitly which functions to export in a DLL. */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
39 #if defined(_WIN32)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
40 #if defined(C_CIRCULAR_QUEUE_BUILD_LIBRARY)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
41 #define C_CIRCULAR_QUEUE_DECLSPEC __declspec(dllexport)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
42 #else
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
43 #define C_CIRCULAR_QUEUE_DECLSPEC __declspec(dllimport)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
44 #endif
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
45 #else
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
46 #if defined(C_CIRCULAR_QUEUE_BUILD_LIBRARY)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
47 #if defined (__GNUC__) && __GNUC__ >= 4
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
48 #define C_CIRCULAR_QUEUE_DECLSPEC __attribute__((visibility("default")))
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
49 #else
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
50 #define C_CIRCULAR_QUEUE_DECLSPEC
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
51 #endif
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
52 #else
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
53 #define C_CIRCULAR_QUEUE_DECLSPEC
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
54 #endif
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
55 #endif
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
56
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
57 /* For Windows, by default, use the C calling convention */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
58 #if defined(_WIN32)
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
59 #define C_CIRCULAR_QUEUE_CALL __cdecl
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
60 #else
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
61 #define C_CIRCULAR_QUEUE_CALL
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
62 #endif
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
63
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
64 /** @endcond DOXYGEN_SHOULD_IGNORE_THIS */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
65 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
66
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
67 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
68 * @file
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
69 * This is a C-based Circular queue class.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
70 * This class provides very simple circular queue functionality,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
71 * with an API similar to the C++ STL queue class.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
72 * Currently, a queue cannot be resized.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
73 * Because C doesn't do templates and I really don't want
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
74 * to write my own polymorphism, you must select the proper queue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
75 * for your data types.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
76 * I currently provide an unisigned int version
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
77 * and a void* version. The void* version will let you use any type,
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
78 * but remember that you are responsible for casting and maintaining
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
79 * your own type safety. I have found the unsigned int version to be
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
80 * very useful because if you have a map somewhere that associates
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
81 * unique identifier numbers to data (e.g. OpenGL displaylists/textures),
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
82 * then you can just deal with the id numbers and don't have to deal with
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
83 * the casting and typesafety issues. I recommend you don't overlook the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
84 * usefulness of this version.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
85 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
86 * @warning Do not mix the CircularQueues created from the different versions.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
87 * They are incompatible. Use only CircularQueueUnsignedInt objects with
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
88 * CircularQueueUnsignedInt_* functions, etc.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
89 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
90 * Example Usage:
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
91 * @code
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
92 * CircularQueueUnsignedInt* myqueue;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
93 * unsigned int ret_val;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
94 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
95 * myqueue = CircularQueueUnsignedInt_CreateQueue(3);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
96 * if(NULL == myqueue)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
97 * {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
98 * fprintf(stderr, "Error, could not create queue\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
99 * return 0;
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
100 * }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
101 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
102 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
103 * ret_val = CircularQueueUnsignedInt_PushBack(myqueue, 1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
104 * ret_val = CircularQueueUnsignedInt_PushBack(myqueue, 2);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
105 * ret_val = CircularQueueUnsignedInt_PushBack(myqueue, 3);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
106 * if(0 == ret_val)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
107 * {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
108 * fprintf(stderr, "Error, Could not pushback\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
109 * exit(1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
110 * }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
111 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
112 * ret_val = CircularQueueUnsignedInt_PopBack(myqueue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
113 * if(0 == ret_val)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
114 * {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
115 * fprintf(stderr, "Error, Could not popback\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
116 * exit(2);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
117 * }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
118 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
119 * fprintf(stderr, "Testing queue, should have 1,2\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
120 * CircularQueueUnsignedInt_Print(myqueue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
121 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
122 * ret_val = CircularQueueUnsignedInt_PushFront(myqueue, 4);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
123 * if(0 == ret_val)
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
124 * {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
125 * fprintf(stderr, "Error, Could not pushfront\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
126 * exit(1);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
127 * }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
128 * fprintf(stderr, "Testing queue, should have 4,1,2\n");
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
129 * CircularQueueUnsignedInt_Print(myqueue);
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
130 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
131 * @endcode
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
132 */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
133
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
134 /* This is a trick I picked up from Lua. Doing the typedef separately
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
135 * (and I guess before the definition) instead of a single
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
136 * entry: typedef struct {...} YourName; seems to allow me
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
137 * to use forward declarations. Doing it the other way (like SDL)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
138 * seems to prevent me from using forward declarions as I get conflicting
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
139 * definition errors. I don't really understand why though.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
140 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
141 typedef struct CircularQueueUnsignedInt CircularQueueUnsignedInt;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
142 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
143 * This is the essentially the CircularQueue object.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
144 * This contains all the data associated with a CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
145 * This version is for unsigned int data types. In the future, I suppose
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
146 * I could add a void* data type at the very least and maybe some
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
147 * other data types.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
148 * This should be considered an opaque data type.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
149 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
150 struct CircularQueueUnsignedInt
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
151 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
152 unsigned int maxSize; /**< Max size of the queue. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
153 unsigned int currentSize; /**< Current number of entries in the queue. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
154 unsigned int headIndex; /**< The index of where the current head is. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
155 unsigned int tailIndex; /**< The index of where the current tail is. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
156 unsigned int* internalQueue; /**< The array representing the queue. */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
157 };
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
158
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
159 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
160 * This creates a new CircularQueue (for unsigned int) instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
161 * This will create a new circular queue instance which holds
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
162 * unsigned int's in its queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
163 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
164 * @note This implementation does not allow a circular queue to be resized.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
165 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
166 * @param max_size This specifies the maximum number of elements the circular
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
167 * can hold.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
168 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
169 * @return Returns a pointer to a CircularQueue which is the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
170 * instance variable (if successful) or NULL on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
171 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
172 * @see CircularQueueUnsignedInt_FreeQueue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
173 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
174 extern C_CIRCULAR_QUEUE_DECLSPEC CircularQueueUnsignedInt* C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_CreateQueue(unsigned int max_size);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
175
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
176 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
177 * This destroys a CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
178 * This will destroy the memory associated with the circular queue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
179 * Whenever you create a CircularQueue instance, you should always to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
180 * remember to balance it with a FreeQueue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
181 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
182 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
183 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
184 * @see CircularQueueUnsignedInt_CreateQueue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
185 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
186 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_FreeQueue(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
187
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
188 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
189 * This pushes a new value into the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
190 * If the queue is full, the function will fail and return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
191 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
192 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
193 * @param value The value you want to push into the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
194 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
195 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
196 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
197 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_PushBack(CircularQueueUnsignedInt* queue, unsigned int value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
198
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
199 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
200 * This pushes a new value into the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
201 * If the queue is full, the function will fail and return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
202 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
203 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
204 * @param value The value you want to push into the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
205 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
206 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
207 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
208 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_PushFront(CircularQueueUnsignedInt* queue, unsigned int value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
209
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
210 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
211 * This removes the value at the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
212 * If the queue is empty, the function will return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
213 * Note that this function does not return the value popped, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
214 * an error flag. If you need the value, you must call Front()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
215 * to retrieve the value before popping it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
216 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
217 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
218 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
219 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
220 * @see CircularQueueUnsignedInt_Front
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
221 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
222 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_PopFront(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
223
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
224 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
225 * This removes the value at the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
226 * If the queue is empty, the function will return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
227 * Note that this function does not return the value popped, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
228 * an error flag. If you need the value, you must call Back()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
229 * to retrieve the value before popping it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
230 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
231 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
232 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
233 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
234 * @see CircularQueueUnsignedInt_Back
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
235 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
236 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_PopBack(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
237
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
238 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
239 * This gets the value at the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
240 * If the queue is empty, the value returned will be 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
241 * Because this 0 return value is ambiguous because it could also could
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
242 * be a legitimate value in the queue, if you need more robust error
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
243 * checking for if the queue is empty, you should get the size of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
244 * queue using the Size() function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
245 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
246 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
247 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
248 * @return Returns the value stored at the queue or 0 if the queue is empty
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
249 * (or if there is an error).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
250 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
251 * @see CircularQueueUnsignedInt_Size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
252 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
253 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_Front(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
254
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
255 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
256 * This gets the value at the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
257 * If the queue is empty, the value returned will be 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
258 * Because this 0 return value is ambiguous because it could also could
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
259 * be a legitimate value in the queue, if you need more robust error
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
260 * checking for if the queue is empty, you should get the size of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
261 * queue using the Size() function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
262 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
263 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
264 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
265 * @return Returns the value stored at the queue or 0 if the queue is empty
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
266 * (or 0 if there is an error).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
267 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
268 * @see CircularQueueUnsignedInt_Size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
269 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
270 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_Back(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
271
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
272 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
273 * This gets the current number of entries that are in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
274 * This is number is not to be confused with the MaxSize.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
275 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
276 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
277 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
278 * @return Returns the number of entries currently in queue, or 0 if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
279 * there is an error.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
280 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
281 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
282 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_Size(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
283
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
284 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
285 * This gets the maximum number of entries that are allowed in the queue at
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
286 * a given time.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
287 * This is the number that you used in the CreateQueue function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
288 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
289 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
290 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
291 * @return Returns the maximum number of entries allowed in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
292 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
293 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_MaxSize(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
294 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
295 * This empties the entire queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
296 * This will remove all entries that are in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
297 * This does not destroy any memory. Use FreeQueue() to actually destroy
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
298 * the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
299 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
300 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
301 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
302 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_Clear(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
303
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
304 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
305 * This is a debugging function that will print all the elements in the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
306 * queue to stderr.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
307 * This function is provided as convenience, but should not be considered
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
308 * as part of the standard API. Treat this function as deprecated
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
309 * as it's implementation may change or be removed entirely.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
310 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
311 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
312 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
313 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_Print(CircularQueueUnsignedInt* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
314
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
315 /**
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
316 * This returns the element located at the specified index,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
317 * where index=0 represents the head/front of the queue.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
318 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
319 * @param queue The pointer to the CircularQueue instance.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
320 * @param the_index The index of the element you want where 0 represents the
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
321 * head/front of the queue and Size-1 is the back.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
322 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
323 * @return Returns the value located at the index on success, or 0 on failure.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
324 * Be careful to not to confuse an error for a legitmate 0 value.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
325 * Any index from 0 to Size-1 (where Size>0) will be a valid index.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
326 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
327 * This example traverses through the whole queue and prints out each value.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
328 * @code
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
329 * fprintf(stderr, "Queue: ");
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
330 * for(i=0;i<CircularQueueUnsignedInt_Size(xValueQueue);i++)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
331 * {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
332 * ret_val = CircularQueueUnsignedInt_ValueAtIndex(xValueQueue, i);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
333 * fprintf(stderr, "%d ", ret_val);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
334 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
335 * }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
336 * fprintf(stderr, "\n");
5
8cb13d89451a Doxygen support and fixes.
Eric Wing <ewing . public |-at-| gmail . com>
parents: 2
diff changeset
337 * @endcode
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
338 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
339 * @note The implementation uses a modulo operation to compute the index, so
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
340 * this may not be the speediest operation in a tight loop.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
341 * This implementation was not optimized for random access, though it still
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
342 * is technically O(1).
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
343 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
344 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
345 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueUnsignedInt_ValueAtIndex(CircularQueueUnsignedInt* queue, unsigned int the_index);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
346
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
347
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
348 /* This is a trick I picked up from Lua. Doing the typedef separately
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
349 * (and I guess before the definition) instead of a single
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
350 * entry: typedef struct {...} YourName; seems to allow me
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
351 * to use forward declarations. Doing it the other way (like SDL)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
352 * seems to prevent me from using forward declarions as I get conflicting
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
353 * definition errors. I don't really understand why though.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
354 */
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
355 typedef struct CircularQueueVoid CircularQueueVoid;
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
356 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
357 * This is the essentially the CircularQueue object.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
358 * This contains all the data associated with a CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
359 * This version is for unsigned int data types. In the future, I suppose
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
360 * I could add a void* data type at the very least and maybe some
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
361 * other data types.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
362 * This should be considered an opaque data type.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
363 */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
364 struct CircularQueueVoid
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
365 {
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
366 unsigned int maxSize; /**< Max size of the queue. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
367 unsigned int currentSize; /**< Current number of entries in the queue. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
368 unsigned int headIndex; /**< The index of where the current head is. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
369 unsigned int tailIndex; /**< The index of where the current tail is. */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
370 void** internalQueue; /**< The array representing the queue. */
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
371 };
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
372
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
373 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
374 * This creates a new CircularQueue (for void* ) instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
375 * This will create a new circular queue instance which holds
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
376 * unsigned int's in its queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
377 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
378 * @note This implementation does not allow a circular queue to be resized.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
379 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
380 * @param max_size This specifies the maximum number of elements the circular
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
381 * can hold.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
382 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
383 * @return Returns a pointer to a CircularQueue which is the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
384 * instance variable (if successful) or NULL on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
385 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
386 * @see CircularQueueVoid_FreeQueue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
387 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
388 extern C_CIRCULAR_QUEUE_DECLSPEC CircularQueueVoid* C_CIRCULAR_QUEUE_CALL CircularQueueVoid_CreateQueue(unsigned int max_size);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
389
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
390 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
391 * This destroys a CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
392 * This will destroy the memory associated with the circular queue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
393 * Whenever you create a CircularQueue instance, you should always to
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
394 * remember to balance it with a FreeQueue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
395 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
396 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
397 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
398 * @see CircularQueueVoid_CreateQueue
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
399 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
400 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueVoid_FreeQueue(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
401
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
402 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
403 * This pushes a new value into the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
404 * If the queue is full, the function will fail and return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
405 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
406 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
407 * @param value The value you want to push into the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
408 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
409 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
410 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
411 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_PushBack(CircularQueueVoid* queue, void* value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
412
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
413 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
414 * This pushes a new value into the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
415 * If the queue is full, the function will fail and return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
416 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
417 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
418 * @param value The value you want to push into the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
419 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
420 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
421 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
422 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_PushFront(CircularQueueVoid* queue, void* value);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
423
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
424 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
425 * This removes the value at the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
426 * If the queue is empty, the function will return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
427 * Note that this function does not return the value popped, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
428 * an error flag. If you need the value, you must call Front()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
429 * to retrieve the value before popping it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
430 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
431 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
432 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
433 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
434 * @see CircularQueueVoid_Front
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
435 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
436 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_PopFront(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
437
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
438 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
439 * This removes the value at the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
440 * If the queue is empty, the function will return 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
441 * Note that this function does not return the value popped, but
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
442 * an error flag. If you need the value, you must call Back()
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
443 * to retrieve the value before popping it.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
444 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
445 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
446 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
447 * @return Returns 1 on success, or 0 on failure.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
448 * @see CircularQueueVoid_Back
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
449 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
450 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_PopBack(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
451
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
452 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
453 * This gets the value at the front of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
454 * If the queue is empty, the value returned will be 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
455 * Because this 0 return value is ambiguous because it could also could
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
456 * be a legitimate value in the queue, if you need more robust error
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
457 * checking for if the queue is empty, you should get the size of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
458 * queue using the Size() function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
459 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
460 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
461 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
462 * @return Returns the value stored at the queue or 0 if the queue is empty
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
463 * (or if there is an error).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
464 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
465 * @see CircularQueueVoid_Size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
466 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
467 extern C_CIRCULAR_QUEUE_DECLSPEC void* C_CIRCULAR_QUEUE_CALL CircularQueueVoid_Front(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
468
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
469 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
470 * This gets the value at the back of the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
471 * If the queue is empty, the value returned will be 0.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
472 * Because this 0 return value is ambiguous because it could also could
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
473 * be a legitimate value in the queue, if you need more robust error
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
474 * checking for if the queue is empty, you should get the size of the
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
475 * queue using the Size() function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
476 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
477 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
478 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
479 * @return Returns the value stored at the queue or 0 if the queue is empty
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
480 * (or 0 if there is an error).
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
481 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
482 * @see CircularQueueVoid_Size
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
483 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
484 extern C_CIRCULAR_QUEUE_DECLSPEC void* C_CIRCULAR_QUEUE_CALL CircularQueueVoid_Back(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
485
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
486 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
487 * This gets the current number of entries that are in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
488 * This is number is not to be confused with the MaxSize.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
489 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
490 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
491 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
492 * @return Returns the number of entries currently in queue, or 0 if
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
493 * there is an error.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
494 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
495 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
496 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_Size(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
497
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
498 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
499 * This gets the maximum number of entries that are allowed in the queue at
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
500 * a given time.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
501 * This is the number that you used in the CreateQueue function.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
502 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
503 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
504 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
505 * @return Returns the maximum number of entries allowed in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
506 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
507 extern C_CIRCULAR_QUEUE_DECLSPEC unsigned int C_CIRCULAR_QUEUE_CALL CircularQueueVoid_MaxSize(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
508 /**
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
509 * This empties the entire queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
510 * This will remove all entries that are in the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
511 * This does not destroy any memory. Use FreeQueue() to actually destroy
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
512 * the queue.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
513 *
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
514 * @param queue The pointer to the CircularQueue instance.
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
515 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
516 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueVoid_Clear(CircularQueueVoid* queue);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
517
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
518 /**
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
519 * This is a debugging function that will print all the addresses
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
520 * of elements in the queue to stderr.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
521 * This function is provided as convenience, but should not be considered
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
522 * as part of the standard API. Treat this function as deprecated
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
523 * as it's implementation may change or be removed entirely.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
524 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
525 * @param queue The pointer to the CircularQueue instance.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
526 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
527 extern C_CIRCULAR_QUEUE_DECLSPEC void C_CIRCULAR_QUEUE_CALL CircularQueueVoid_Print(CircularQueueVoid* queue);
1
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
528
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
529 /**
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
530 * This returns the element located at the specified index,
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
531 * where index=0 represents the head/front of the queue.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
532 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
533 * @param queue The pointer to the CircularQueue instance.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
534 * @param the_index The index of the element you want where 0 represents the
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
535 * head/front of the queue and Size-1 is the back.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
536 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
537 * @return Returns the element located at the index on success, or NULL on failure.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
538 * Be careful to not to confuse an error for a legitmate NULL value.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
539 * Any index from 0 to Size-1 (where Size>0) will be a valid index.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
540 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
541 * This example traverses through the whole queue and prints out each value.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
542 * @code
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
543 * fprintf(stderr, "Queue: ");
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
544 * for(i=0;i<CircularQueueVoid_ValueAtIndex(xValueQueue);i++)
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
545 * {
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
546 * void* ret_val = CircularQueueUnsignedInt_ValueAtIndex(xValueQueue, i);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
547 * fprintf(stderr, "%x ", ret_val);
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
548 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
549 * }
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
550 * fprintf(stderr, "\n");
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
551 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
552 * @note The implementation uses a modulo operation to compute the index, so
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
553 * this may not be the speediest operation in a tight loop.
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
554 * This implementation was not optimized for random access, though it still
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
555 * is technically O(1).
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
556 *
a8a8fe374984 Subversion era
Eric Wing <ewing . public |-at-| gmail . com>
parents: 0
diff changeset
557 */
54
516da6d93534 Added explicit symbol visibility markers to support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents: 5
diff changeset
558 extern C_CIRCULAR_QUEUE_DECLSPEC void* C_CIRCULAR_QUEUE_CALL CircularQueueVoid_ValueAtIndex(CircularQueueVoid* queue, unsigned int the_index);
0
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
559
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
560
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
561
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
562
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
563 /* Ends C function definitions when using C++ */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
564 #ifdef __cplusplus
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
565 }
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
566 #endif
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
567
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
568
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
569
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
570 #endif /* C_CIRCULAR_QUEUE_H */
01e39f9f58d5 Bitkeeper era.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
diff changeset
571