20#include <lal/LALStdlib.h>
21#include <lal/LALDict.h>
22#include <lal/LALDictSequence.h>
28 for (
size_t i = 0; i < sequence->length; ++i)
39 LALDictSequence *sequence;
42 sequence->length = length;
43 sequence->data =
LALCalloc(length,
sizeof(*sequence->data));
44 if (sequence->data == NULL) {
48 for (
size_t i = 0; i < length; ++i) {
50 if (sequence->data[i] == NULL) {
65 for (
size_t i = 0; i < length; ++i) {
66 int retval =
XLALDictUpdate(new->data[i], sequence->data[i + first]);
86 size_t right =
end - 1;
87 while (left < right) {
88 LALDict *tmp =
a[left];
104 modabscount = abs(count) % sequence->length;
105 shift = count > 0 ? sequence->length - modabscount: modabscount;
108 reverse(sequence->data, 0, shift);
109 reverse(sequence->data, shift, sequence->length);
110 reverse(sequence->data, 0, sequence->length);
117 size_t abscount = count > 0 ? count : -count;
125 if (abscount >= sequence->length) {
127 for (
size_t i = 0; i < sequence->length; ++i)
129 }
else if (count < 0) {
131 for (
size_t i = 0; i < abscount; ++i)
137 for (
size_t i = 0; i < abscount; ++i)
150 if (length > sequence->length) {
151 data =
XLALRealloc(sequence->data, length *
sizeof(*sequence->data));
153 for (
size_t i = sequence->length; i < length; ++i)
155 sequence->data = data;
156 sequence->length = length;
158 }
else if (length > 0) {
160 for (
size_t i = length; i < sequence->length; ++i)
162 data =
XLALRealloc(sequence->data, length *
sizeof(*sequence->data));
164 sequence->data = data;
165 sequence->length = length;
167 for (
size_t i = 0; i < sequence->length; ++i)
170 sequence->data = NULL;
171 sequence->length = 0;
180 return sequence->length;
188 pos += sequence->length;
198 pos += sequence->length;
int XLALDictUpdate(LALDict *dst, const LALDict *src)
void XLALDestroyDict(LALDict *dict)
LALDict * XLALDictDuplicate(const LALDict *orig)
LALDict * XLALCreateDict(void)
void XLALClearDict(LALDict *dict)
void XLALDestroyDictSequence(LALDictSequence *sequence)
LALDictSequence * XLALCopyDictSequence(const LALDictSequence *sequence)
void XLALRollDictSequence(LALDictSequence *sequence, int count)
LALDict * XLALDictSequenceGet(LALDictSequence *sequence, int pos)
LALDictSequence * XLALResizeDictSequence(LALDictSequence *sequence, int first, size_t length)
void XLALShiftDictSequence(LALDictSequence *sequence, int count)
LALDictSequence * XLALCutDictSequence(const LALDictSequence *sequence, size_t first, size_t length)
int XLALDictSequenceSet(LALDictSequence *sequence, LALDict *dict, int pos)
LALDictSequence * XLALCreateDictSequence(size_t length)
size_t XLALDictSequenceLength(LALDictSequence *sequence)
static void reverse(LALDict **a, size_t start, size_t end)
#define XLALRealloc(p, n)
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_VOID(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns void.
#define XLAL_CHECK_NULL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a pointe...
@ XLAL_EBADLEN
Inconsistent or invalid length.
@ XLAL_ENOMEM
Memory allocation error.
@ XLAL_EFAULT
Invalid pointer.
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
@ XLAL_EINVAL
Invalid argument.