#pragma once
#include <stdint.h>

/* UInt8 */

struct LengthPrefixUInt8Array {
    uint64_t len;
    uint8_t items[];
};

void length_prefix_uint8_array_clear(
    struct LengthPrefixUInt8Array * data
);
void length_prefix_uint8_array_push(
    struct LengthPrefixUInt8Array * data,
    uint8_t value
);
int length_prefix_uint8_array_reverse(
    struct LengthPrefixUInt8Array const * restrict src,
    struct LengthPrefixUInt8Array * restrict dst
);
void length_prefix_uint8_array_dump(
    struct LengthPrefixUInt8Array const * data
);

/* UInt64 */

struct LengthPrefixUInt64Array {
    uint64_t len;
    uint64_t items[];
};

void length_prefix_uint64_array_clear(
    struct LengthPrefixUInt64Array * data
);
void length_prefix_uint64_array_push(
    struct LengthPrefixUInt64Array * data,
    uint64_t value
);
int length_prefix_uint64_array_reverse(
    struct LengthPrefixUInt64Array const * restrict src,
    struct LengthPrefixUInt64Array * restrict dst
);
void length_prefix_uint64_array_dump(
    struct LengthPrefixUInt64Array const * data
);

/*
 * Map
 */
int length_prefix_array_map_64_to_64(
    int (*f) ( uint64_t const * restrict, uint64_t * restrict ),
    struct LengthPrefixUInt64Array const * restrict src,
    struct LengthPrefixUInt64Array * restrict dst
);
int length_prefix_array_map_8_to_64(
    int (*f) ( uint8_t const * restrict, uint64_t * restrict ),
    struct LengthPrefixUInt8Array const * restrict src,
    struct LengthPrefixUInt64Array * restrict dst
);
int length_prefix_array_map_64_to_8(
    int (*f) ( uint64_t const * restrict, uint8_t * restrict ),
    struct LengthPrefixUInt64Array const * restrict src,
    struct LengthPrefixUInt8Array * restrict dst
);