Skip to content

Commit 80cf620

Browse files
committed
Slice
1 parent 9172252 commit 80cf620

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/AudioBasic/Collections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
#include "AudioBasic/Collections/List.h"
1010
#include "AudioBasic/Collections/Stack.h"
1111
#include "AudioBasic/Collections/Queue.h"
12-
#include "AudioBasic/Collections/BitVector.h"
12+
#include "AudioBasic/Collections/BitVector.h"
13+
#include "AudioBasic/Collections/Slice.h"

src/AudioBasic/Collections/Slice.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace audio_tools {
77
/**
88
* @brief Helps to split up a big memory array into smaller slices. There are no
99
* additinal heap allocations!
10+
* Example: if we have an array with 9 entries (1,2,3,4,5,6,7,8,9): slices(5) gives 2.
11+
* slice(5,0) returns size 5 with 1,2,3,4,5 and slice(5,1) returns size 4 with 6,7,8,9!
1012
* @ingroup collections
1113
* @author Phil Schatzmann
1214
*/
@@ -24,15 +26,15 @@ class Slice {
2426
/// Returns the (result) data size in bytes
2527
size_t size() { return len; }
2628

27-
/// Returns the number of slices
29+
/// Returns the number of slices of the indicated size
2830
size_t slices(int sliceSize){
2931
int result = len / sliceSize;
3032
return len % sliceSize == 0 ? result : result+1;
3133
}
3234

3335
operator bool() { return len > 0; }
3436

35-
/// Returns the slice at the indicated index;
37+
/// Returns the slice at the indicated index for the indicated slize size;
3638
Slice slice(int sliceSize, int idx) {
3739
int start_pos = idx * sliceSize;
3840
int end_pos = start_pos + sliceSize;

0 commit comments

Comments
 (0)