// Copyright 2026, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Hannah Bast <bast@cs.uni-freiburg.de>.
// Author: Christoph Ullinger <ullingec@cs.uni-freiburg.de>.
#pragma once
#include <gtest/gtest_prod.h>
// A simple array that knows its size. Element type: T.
template<typename T>
class Array {
public:
// Create from given C-style array.
Array(T *array, int n);
// Destructor.
~Array();
// Get the element with index i.
T operator[](int i) const;
private:
// The elements of the array.
T *elements_;
// The number of elements.
int size_;
FRIEND_TEST(ArrayTest, Array);
};
// A simple array that knows its size. Element type: bool.
template<>
class Array<bool> {
public:
// Create from given C-style array.
Array(bool *array, int n);
// Destructor.
~Array();
// Get the element with index i.
bool operator[](int i) const;
private:
// The elements of the array.
char elements_;
// The number of elements.
int size_;
FRIEND_TEST(ArrayTest, Array);
};
// A simple array that knows its size. Element type: int.
class ArrayInt {
public:
// Create from given C-style array.
ArrayInt(int *array, int n);
// Destructor.
~ArrayInt();
// Get the element with index i.
int operator[](int i) const;
private:
// The elements of the array.
int *elements_;
// The number of elements.
int size_;
FRIEND_TEST(ArrayTest, ArrayInt);
};
// A simple array that knows its size. Element type: float.
class ArrayFloat {
public:
// Create from given C-style array.
ArrayFloat(float *array, int n);
// Destructor.
~ArrayFloat();
// Get the element with index i.
float operator[](int i) const;
private:
// The elements of the array.
float *elements_;
// The number of elements.
int size_;
FRIEND_TEST(ArrayTest, ArrayFloat);
};