[Glacier] Add a basic Array and ArrayView class.
This commit is contained in:
parent
1643f7b4cc
commit
6feb13d042
2 changed files with 86 additions and 0 deletions
27
lib/glacier/container/array_view.h
Normal file
27
lib/glacier/container/array_view.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace glcr {
|
||||
|
||||
template <typename T>
|
||||
class ArrayView {
|
||||
public:
|
||||
ArrayView() : data_(nullptr), size_(0) {}
|
||||
ArrayView(const ArrayView&) = default;
|
||||
ArrayView(T* data, uint64_t size) : data_(data), size_(size) {}
|
||||
|
||||
T* RawPtr() { return data_; }
|
||||
const T* RawPtr() const { return data_; }
|
||||
|
||||
uint64_t size() const { return size_; }
|
||||
|
||||
T& operator[](uint64_t index) { return data_[index]; }
|
||||
const T& operator[](uint64_t index) const { return data_[index]; }
|
||||
|
||||
private:
|
||||
T* data_;
|
||||
uint64_t size_;
|
||||
};
|
||||
|
||||
} // namespace glcr
|
||||
Loading…
Add table
Add a link
Reference in a new issue