Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lizhongxiao
OpenXG-RAN
Commits
f25fa70f
Commit
f25fa70f
authored
Nov 23, 2023
by
Robert Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apply clang-format
parent
e8824827
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
160 deletions
+148
-160
common/utils/alg/find.c
common/utils/alg/find.c
+8
-9
common/utils/alg/find.h
common/utils/alg/find.h
+18
-19
common/utils/alg/foreach.c
common/utils/alg/foreach.c
+2
-4
common/utils/alg/foreach.h
common/utils/alg/foreach.h
+6
-6
common/utils/ds/seq_arr.c
common/utils/ds/seq_arr.c
+30
-33
common/utils/ds/seq_arr.h
common/utils/ds/seq_arr.h
+66
-66
common/utils/ds/tests/test_seq_array.c
common/utils/ds/tests/test_seq_array.c
+18
-23
No files found.
common/utils/alg/find.c
View file @
f25fa70f
...
...
@@ -27,24 +27,23 @@ SOFTWARE.
#include <stdlib.h>
#include <stdio.h>
elm_arr_t
find_if_arr_it
(
seq_arr_t
*
arr
,
void
*
start_it
,
void
*
end_it
,
void
*
value
,
bool
(
*
f
)(
const
void
*
,
const
void
*
))
elm_arr_t
find_if_arr_it
(
seq_arr_t
*
arr
,
void
*
start_it
,
void
*
end_it
,
void
*
value
,
bool
(
*
f
)(
const
void
*
,
const
void
*
))
{
assert
(
arr
!=
NULL
);
while
(
start_it
!=
end_it
)
{
if
(
f
(
value
,
start_it
))
return
(
elm_arr_t
){.
found
=
true
,
.
it
=
start_it
};
start_it
=
seq_arr_next
(
arr
,
start_it
);
while
(
start_it
!=
end_it
)
{
if
(
f
(
value
,
start_it
))
return
(
elm_arr_t
){.
found
=
true
,
.
it
=
start_it
};
start_it
=
seq_arr_next
(
arr
,
start_it
);
}
// If I trusted the average developer I should return it=start_it, but I don't.
return
(
elm_arr_t
){.
found
=
false
,
.
it
=
NULL
};
return
(
elm_arr_t
){.
found
=
false
,
.
it
=
NULL
};
}
elm_arr_t
find_if_arr
(
seq_arr_t
*
arr
,
void
*
value
,
bool
(
*
f
)(
const
void
*
,
const
void
*
))
elm_arr_t
find_if_arr
(
seq_arr_t
*
arr
,
void
*
value
,
bool
(
*
f
)(
const
void
*
,
const
void
*
))
{
assert
(
arr
!=
NULL
);
void
*
start_it
=
seq_arr_front
(
arr
);
void
*
end_it
=
seq_arr_end
(
arr
);
void
*
end_it
=
seq_arr_end
(
arr
);
return
find_if_arr_it
(
arr
,
start_it
,
end_it
,
value
,
f
);
}
common/utils/alg/find.h
View file @
f25fa70f
...
...
@@ -23,12 +23,12 @@ SOFTWARE.
*/
#ifndef FIND_ALGORITHM
#define FIND_ALGORITHM
#define FIND_ALGORITHM
#include <stdbool.h>
#include "../ds/seq_arr.h"
typedef
struct
{
typedef
struct
{
void
*
it
;
bool
found
;
}
elm_arr_t
;
...
...
@@ -36,24 +36,23 @@ typedef struct{
// Sequencial containers
/**
* @brief Find elements in an array if the predicate is true
* @param arr The sequence container
* @param value Pointer to the value that will be used by the predicate
* @param f Function representing the predicate
* @return Whether the predicate was fullfilled and the iterator to the element if true
*/
elm_arr_t
find_if_arr
(
seq_arr_t
*
arr
,
void
*
value
,
bool
(
*
f
)(
const
void
*
value
,
const
void
*
it
));
* @brief Find elements in an array if the predicate is true
* @param arr The sequence container
* @param value Pointer to the value that will be used by the predicate
* @param f Function representing the predicate
* @return Whether the predicate was fullfilled and the iterator to the element if true
*/
elm_arr_t
find_if_arr
(
seq_arr_t
*
arr
,
void
*
value
,
bool
(
*
f
)(
const
void
*
value
,
const
void
*
it
));
/**
* @brief Find elements in an array in the semi-open range [start_it, end_it)
* @param arr The sequence container
* @param start_it Iterator to the first element
* @param end_it Iterator to the one past last element
* @param value Pointer to the value usied in the predicate
* @param f Function representing the predicate
* @return Whether the predicate was fullfilled and the iterator to the element if true
*/
elm_arr_t
find_if_arr_it
(
seq_arr_t
*
arr
,
void
*
start_it
,
void
*
end_it
,
void
*
value
,
bool
(
*
f
)(
const
void
*
value
,
const
void
*
it
));
* @brief Find elements in an array in the semi-open range [start_it, end_it)
* @param arr The sequence container
* @param start_it Iterator to the first element
* @param end_it Iterator to the one past last element
* @param value Pointer to the value usied in the predicate
* @param f Function representing the predicate
* @return Whether the predicate was fullfilled and the iterator to the element if true
*/
elm_arr_t
find_if_arr_it
(
seq_arr_t
*
arr
,
void
*
start_it
,
void
*
end_it
,
void
*
value
,
bool
(
*
f
)(
const
void
*
value
,
const
void
*
it
));
#endif
common/utils/alg/foreach.c
View file @
f25fa70f
...
...
@@ -33,10 +33,8 @@ void for_each(seq_arr_t* arr, void* value, void (*f)(void* value, void* it))
void
*
it
=
seq_arr_front
(
arr
);
void
*
end
=
seq_arr_end
(
arr
);
while
(
it
!=
end
)
{
while
(
it
!=
end
)
{
f
(
value
,
it
);
it
=
seq_arr_next
(
arr
,
it
);
it
=
seq_arr_next
(
arr
,
it
);
}
}
common/utils/alg/foreach.h
View file @
f25fa70f
...
...
@@ -23,16 +23,16 @@ SOFTWARE.
*/
#ifndef FOR_EACH_ALGORITHM
#define FOR_EACH_ALGORITHM
#define FOR_EACH_ALGORITHM
#include "../ds/seq_arr.h"
/**
* @brief Apply function to each element in the sequence container
* @param arr The sequence container
* @param value Pointer to the value that will be used by the function applied
* @param fn_apply Function called by every element in the sequence container
*/
* @brief Apply function to each element in the sequence container
* @param arr The sequence container
* @param value Pointer to the value that will be used by the function applied
* @param fn_apply Function called by every element in the sequence container
*/
void
for_each
(
seq_arr_t
*
arr
,
void
*
value
,
void
(
*
fn_apply
)(
void
*
value
,
void
*
it
));
#endif
common/utils/ds/seq_arr.c
View file @
f25fa70f
...
...
@@ -29,30 +29,27 @@ SOFTWARE.
#include <stdio.h>
#include <string.h>
static
const
size_t
MIN_SIZE
=
8
;
static
const
size_t
MIN_SIZE
=
8
;
static
void
maybe_expand
(
seq_arr_t
*
arr
)
static
void
maybe_expand
(
seq_arr_t
*
arr
)
{
if
(
arr
->
size
+
1
==
arr
->
cap
)
{
arr
->
data
=
realloc
(
arr
->
data
,
2
*
arr
->
cap
*
arr
->
elt_size
);
if
(
arr
->
size
+
1
==
arr
->
cap
)
{
arr
->
data
=
realloc
(
arr
->
data
,
2
*
arr
->
cap
*
arr
->
elt_size
);
assert
(
arr
->
data
!=
NULL
&&
"realloc failed to allocate memory"
);
arr
->
cap
*=
2
;
arr
->
cap
*=
2
;
}
}
static
void
maybe_shrink
(
seq_arr_t
*
arr
)
static
void
maybe_shrink
(
seq_arr_t
*
arr
)
{
const
float
occ
=
(
float
)
arr
->
size
/
(
float
)
arr
->
cap
;
if
(
arr
->
size
>
MIN_SIZE
&&
occ
<
0
.
25
)
{
assert
(
arr
->
cap
>
MIN_SIZE
);
seq_arr_t
tmp
=
{.
data
=
NULL
,
.
size
=
arr
->
size
,
.
elt_size
=
arr
->
elt_size
,
.
cap
=
arr
->
cap
/
2
};
const
float
occ
=
(
float
)
arr
->
size
/
(
float
)
arr
->
cap
;
if
(
arr
->
size
>
MIN_SIZE
&&
occ
<
0
.
25
)
{
assert
(
arr
->
cap
>
MIN_SIZE
);
seq_arr_t
tmp
=
{.
data
=
NULL
,
.
size
=
arr
->
size
,
.
elt_size
=
arr
->
elt_size
,
.
cap
=
arr
->
cap
/
2
};
tmp
.
data
=
calloc
(
tmp
.
cap
,
tmp
.
cap
);
assert
(
tmp
.
data
!=
NULL
&&
"Memory exhausted"
);
assert
(
arr
->
size
<=
tmp
.
cap
);
memcpy
(
tmp
.
data
,
arr
->
data
,
arr
->
size
*
arr
->
elt_size
);
memcpy
(
tmp
.
data
,
arr
->
data
,
arr
->
size
*
arr
->
elt_size
);
free
(
arr
->
data
);
memcpy
(
arr
,
&
tmp
,
sizeof
(
seq_arr_t
));
}
...
...
@@ -67,16 +64,16 @@ void seq_arr_init(seq_arr_t* arr, size_t elt_size) //__attribute__(malloc)
assert
(
arr
->
data
!=
NULL
);
}
void
seq_arr_free
(
seq_arr_t
*
arr
,
void
(
*
free_func
)(
void
*
)
)
void
seq_arr_free
(
seq_arr_t
*
arr
,
void
(
*
free_func
)(
void
*
))
{
assert
(
arr
!=
NULL
);
assert
(
arr
->
data
!=
NULL
);
if
(
free_func
!=
NULL
)
{
if
(
free_func
!=
NULL
)
{
void
*
start_it
=
seq_arr_front
(
arr
);
void
*
end_it
=
seq_arr_end
(
arr
);
while
(
start_it
!=
end_it
)
{
free_func
(
start_it
);
while
(
start_it
!=
end_it
)
{
free_func
(
start_it
);
start_it
=
seq_arr_next
(
arr
,
start_it
);
}
}
...
...
@@ -88,12 +85,12 @@ void seq_arr_push_back(seq_arr_t* arr, void* data, size_t len)
{
assert
(
arr
!=
NULL
);
assert
(
arr
->
data
!=
NULL
);
//assert(data != NULL);
//
assert(data != NULL);
assert
(
len
==
arr
->
elt_size
);
maybe_expand
(
arr
);
const
size_t
offset
=
arr
->
size
*
arr
->
elt_size
;
const
size_t
offset
=
arr
->
size
*
arr
->
elt_size
;
memcpy
(
&
arr
->
data
[
offset
],
data
,
arr
->
elt_size
);
arr
->
size
+=
1
;
}
...
...
@@ -111,7 +108,7 @@ void seq_arr_erase_deep(seq_arr_t* arr, void* start_it, void (*free_func)(void*
// start_it must be in the range of arr->data
assert
(
arr
!=
NULL
);
assert
(
start_it
!=
NULL
);
return
seq_arr_erase_it
(
arr
,
start_it
,
seq_arr_next
(
arr
,
start_it
),
free_func
);
return
seq_arr_erase_it
(
arr
,
start_it
,
seq_arr_next
(
arr
,
start_it
),
free_func
);
}
void
seq_arr_erase_it
(
seq_arr_t
*
arr
,
void
*
start_it
,
void
*
end_it
,
void
(
*
free_func
)(
void
*
it
))
...
...
@@ -120,25 +117,26 @@ void seq_arr_erase_it(seq_arr_t* arr, void* start_it, void* end_it, void (*free_
assert
(
arr
!=
NULL
);
assert
(
start_it
!=
NULL
);
assert
(
end_it
!=
NULL
);
assert
(
end_it
>=
start_it
);
assert
(
end_it
>=
start_it
);
if
(
start_it
==
end_it
)
return
;
if
(
start_it
==
end_it
)
return
;
if
(
free_func
!=
NULL
)
{
if
(
free_func
!=
NULL
)
{
void
*
start_it
=
seq_arr_front
(
arr
);
void
*
end_it
=
seq_arr_end
(
arr
);
while
(
start_it
!=
end_it
)
{
free_func
(
start_it
);
while
(
start_it
!=
end_it
)
{
free_func
(
start_it
);
start_it
=
seq_arr_next
(
arr
,
start_it
);
}
}
const
int
num_bytes_move
=
seq_arr_end
(
arr
)
-
end_it
;
assert
(
num_bytes_move
>
-
1
);
memmove
(
start_it
,
end_it
,
num_bytes_move
);
memmove
(
start_it
,
end_it
,
num_bytes_move
);
const
int
num_bytes_erase
=
end_it
-
start_it
;
const
int32_t
num_elm_erase
=
num_bytes_erase
/
arr
->
elt_size
;
const
int32_t
num_elm_erase
=
num_bytes_erase
/
arr
->
elt_size
;
assert
(
num_elm_erase
>
0
);
arr
->
size
-=
num_elm_erase
;
...
...
@@ -170,7 +168,7 @@ void* seq_arr_end(seq_arr_t const* arr)
{
assert
(
arr
!=
NULL
);
assert
(
arr
->
data
!=
NULL
);
return
&
arr
->
data
[
arr
->
size
*
arr
->
elt_size
];
return
&
arr
->
data
[
arr
->
size
*
arr
->
elt_size
];
}
void
*
seq_arr_at
(
seq_arr_t
const
*
arr
,
uint32_t
pos
)
...
...
@@ -178,7 +176,7 @@ void* seq_arr_at(seq_arr_t const* arr, uint32_t pos)
assert
(
arr
!=
NULL
);
assert
(
arr
->
data
!=
NULL
);
assert
(
pos
<
arr
->
size
);
return
arr
->
data
+
pos
*
arr
->
elt_size
;
return
arr
->
data
+
pos
*
arr
->
elt_size
;
}
ptrdiff_t
seq_arr_dist
(
seq_arr_t
const
*
arr
,
void
const
*
first
,
void
const
*
last
)
...
...
@@ -186,8 +184,7 @@ ptrdiff_t seq_arr_dist(seq_arr_t const* arr, void const* first, void const* last
assert
(
arr
!=
NULL
);
assert
(
first
!=
NULL
);
assert
(
last
!=
NULL
);
const
ptrdiff_t
pos
=
(
last
-
first
)
/
arr
->
elt_size
;
const
ptrdiff_t
pos
=
(
last
-
first
)
/
arr
->
elt_size
;
assert
(
pos
>
-
1
);
return
pos
;
}
common/utils/ds/seq_arr.h
View file @
f25fa70f
...
...
@@ -26,7 +26,7 @@ SOFTWARE.
#define SEQ_CONTAINER_ARRAY
/*
* Basic sequence container with a similar API and behaviour to C++ std::vector
* Basic sequence container with a similar API and behaviour to C++ std::vector
*/
#include <stdbool.h>
...
...
@@ -34,67 +34,68 @@ SOFTWARE.
#include <stdlib.h>
#include <stdint.h>
typedef
struct
seq_arr_s
{
uint8_t
*
data
;
size_t
size
;
const
size_t
elt_size
;
size_t
cap
;
typedef
struct
seq_arr_s
{
uint8_t
*
data
;
size_t
size
;
const
size_t
elt_size
;
size_t
cap
;
}
seq_arr_t
;
/**
* Init a sequence container, similar to a constructor
* @brief Constructor.
* @param arr The sequence container
* @param elm_sz value returned by the sizeof operator of the type that the container will hold e.g., sizeof(int).
*/
* Init a sequence container, similar to a constructor
* @brief Constructor.
* @param arr The sequence container
* @param elm_sz value returned by the sizeof operator of the type that the container will hold e.g., sizeof(int).
*/
void
seq_arr_init
(
seq_arr_t
*
arr
,
size_t
elm_sz
);
/**
* Free a sequence container, similar to a destructor
* @brief Destructor.
* @param arr The sequence container
* @param free_func Function called for every element while destructing e.g., useful to free memory of deep objects.
*/
* Free a sequence container, similar to a destructor
* @brief Destructor.
* @param arr The sequence container
* @param free_func Function called for every element while destructing e.g., useful to free memory of deep objects.
*/
void
seq_arr_free
(
seq_arr_t
*
arr
,
void
(
*
free_func
)(
void
*
it
));
/**
* @brief Push back elements into the sequence container. Value semantic. i.e., the void* data will be shallowly copied in the array.
* @param arr The sequence container
* @param data Pointer to the data to be copied
* @param elm_sz Size of the element to be copied e.g., sizeof(int)
*/
* @brief Push back elements into the sequence container. Value semantic. i.e., the void* data will be shallowly copied in the
* array.
* @param arr The sequence container
* @param data Pointer to the data to be copied
* @param elm_sz Size of the element to be copied e.g., sizeof(int)
*/
void
seq_arr_push_back
(
seq_arr_t
*
arr
,
void
*
data
,
size_t
elm_sz
);
/**
* @brief Erase the element pointed by it
* @param arr The sequence container
* @param it Iterator to the element to erase
*/
* @brief Erase the element pointed by it
* @param arr The sequence container
* @param it Iterator to the element to erase
*/
void
seq_arr_erase
(
seq_arr_t
*
,
void
*
it
);
/**
* @brief Erase the element pointed by it and call the f function. Useful to free deep copies
* @param arr The sequence container
* @param it Iterator to the element to erase
* @param free_func Function to call while erasing element
*/
* @brief Erase the element pointed by it and call the f function. Useful to free deep copies
* @param arr The sequence container
* @param it Iterator to the element to erase
* @param free_func Function to call while erasing element
*/
void
seq_arr_erase_deep
(
seq_arr_t
*
arr
,
void
*
it
,
void
(
*
free_func
)(
void
*
it
));
/**
* @brief Erase the elements in the semi-open range [first,last)
* @param arr The sequence container
* @param first Iterator to the first element to erase
* @param last Iterator to the last element. Note that this element will NOT be erased
* @param f Function that will be called by every element while erasing. Useful for deep copies. Pass NULL if shallow
* erased required
*/
* @brief Erase the elements in the semi-open range [first,last)
* @param arr The sequence container
* @param first Iterator to the first element to erase
* @param last Iterator to the last element. Note that this element will NOT be erased
* @param f Function that will be called by every element while erasing. Useful for deep copies. Pass NULL if shallow
* erased required
*/
void
seq_arr_erase_it
(
seq_arr_t
*
arr
,
void
*
first
,
void
*
last
,
void
(
*
free_func
)(
void
*
it
));
/**
* @brief Elements in the array
* @param arr The sequence container
* @return The number of elements in the sequence container
*/
* @brief Elements in the array
* @param arr The sequence container
* @return The number of elements in the sequence container
*/
size_t
seq_arr_size
(
seq_arr_t
const
*
arr
);
/////
...
...
@@ -102,43 +103,42 @@ size_t seq_arr_size(seq_arr_t const* arr);
/////
/**
* @brief First iterator
* @param arr The sequence container
* @return The iterator to the first element in the sequence container
*/
* @brief First iterator
* @param arr The sequence container
* @return The iterator to the first element in the sequence container
*/
void
*
seq_arr_front
(
seq_arr_t
const
*
arr
);
/**
* @brief Next iterator
* @param arr The sequence container
* @param it Iterator to a valid element
* @return The iterator to the next element in the sequence container
*/
* @brief Next iterator
* @param arr The sequence container
* @param it Iterator to a valid element
* @return The iterator to the next element in the sequence container
*/
void
*
seq_arr_next
(
seq_arr_t
const
*
arr
,
void
const
*
it
);
/**
* @brief End iterator
* @param arr The sequence container
* @return The iterator to one past the last element in the sequence container
*/
* @brief End iterator
* @param arr The sequence container
* @return The iterator to one past the last element in the sequence container
*/
void
*
seq_arr_end
(
seq_arr_t
const
*
arr
);
/**
* @brief Returns iterator in positions pos
* @param arr The sequence container
* @param pos The position of the element in the sequence container
* @return The iterator to the element
*/
* @brief Returns iterator in positions pos
* @param arr The sequence container
* @param pos The position of the element in the sequence container
* @return The iterator to the element
*/
void
*
seq_arr_at
(
seq_arr_t
const
*
arr
,
uint32_t
pos
);
/**
* @brief Distance between iterators
* @param arr The sequence container
* @param first Iterator to first element
* @param last Iterator to last element
* @return The distance among iterators
*/
* @brief Distance between iterators
* @param arr The sequence container
* @param first Iterator to first element
* @param last Iterator to last element
* @return The distance among iterators
*/
ptrdiff_t
seq_arr_dist
(
seq_arr_t
const
*
arr
,
void
const
*
first
,
void
const
*
last
);
#endif
common/utils/ds/tests/test_seq_array.c
View file @
f25fa70f
...
...
@@ -4,39 +4,35 @@
#include <assert.h>
/*
Example to show seq_arr_t capabilities and usage
Example to show seq_arr_t capabilities and usage
To compile: gcc test_seq_array.c ../seq_arr.c ../../alg/find.c ../../alg/foreach.c
*/
static
bool
eq_int
(
const
void
*
value
,
const
void
*
it
)
static
bool
eq_int
(
const
void
*
value
,
const
void
*
it
)
{
const
int
*
v
=
(
const
int
*
)
value
;
const
int
*
v
=
(
const
int
*
)
value
;
const
int
*
i
=
(
const
int
*
)
it
;
return
*
v
==
*
i
;
}
static
void
sum_elm
(
void
*
value
,
void
*
it
)
static
void
sum_elm
(
void
*
value
,
void
*
it
)
{
int
*
sum
=
(
int
*
)
value
;
int
*
sum
=
(
int
*
)
value
;
int
*
elm
=
(
int
*
)
it
;
*
sum
+=
*
elm
;
}
static
int
compar
(
const
void
*
m0
,
const
void
*
m1
)
static
int
compar
(
const
void
*
m0
,
const
void
*
m1
)
{
int
*
a
=
(
int
*
)
m0
;
int
*
b
=
(
int
*
)
m1
;
if
(
*
a
<
*
b
)
int
*
a
=
(
int
*
)
m0
;
int
*
b
=
(
int
*
)
m1
;
if
(
*
a
<
*
b
)
return
-
1
;
if
(
*
a
==
*
b
)
if
(
*
a
==
*
b
)
return
0
;
return
1
;
}
...
...
@@ -46,7 +42,7 @@ int main()
seq_arr_init
(
&
arr
,
sizeof
(
int
));
// Insert data and expand
for
(
int
i
=
0
;
i
<
100
;
++
i
)
for
(
int
i
=
0
;
i
<
100
;
++
i
)
seq_arr_push_back
(
&
arr
,
&
i
,
sizeof
(
int
));
// Check inserted data
...
...
@@ -58,7 +54,7 @@ int main()
int
value
=
50
;
elm_arr_t
elm
=
find_if_arr
(
&
arr
,
&
value
,
eq_int
);
assert
(
elm
.
found
==
true
);
//Check
//
Check
assert
(
*
(
int
*
)
elm
.
it
==
50
);
assert
(
seq_arr_dist
(
&
arr
,
seq_arr_front
(
&
arr
),
elm
.
it
)
==
50
);
...
...
@@ -74,12 +70,12 @@ int main()
assert
(
*
(
int
*
)
seq_arr_at
(
&
arr
,
50
)
==
51
);
// Erase range and force shrink
seq_arr_erase_it
(
&
arr
,
seq_arr_front
(
&
arr
),
seq_arr_at
(
&
arr
,
90
)
,
NULL
);
seq_arr_erase_it
(
&
arr
,
seq_arr_front
(
&
arr
),
seq_arr_at
(
&
arr
,
90
)
,
NULL
);
assert
(
seq_arr_size
(
&
arr
)
==
9
);
assert
(
*
(
int
*
)
seq_arr_front
(
&
arr
)
==
91
);
//Recall that C functions qsort and bsearch, also work
int
key
=
95
;
//
Recall that C functions qsort and bsearch, also work
int
key
=
95
;
void
*
base
=
seq_arr_front
(
&
arr
);
size_t
nmemb
=
seq_arr_size
(
&
arr
);
size_t
size
=
sizeof
(
int
);
...
...
@@ -92,4 +88,3 @@ int main()
return
EXIT_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment