flatten 20260225

This commit is contained in:
Timothy Prepscius
2026-02-25 12:43:06 -05:00
commit 996151a56a
521 changed files with 46722 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
// License: Modified MIT (NON-AI)
// See the LICENSE file in the root directory for license information.
// Copyright 2025 Timothy Prepscius
#pragma once
#include "FilledArray.h"
#include "StackArray.hpp"
#include "../debug/Debug.h"
#include "../assert/debug_assert.h"
#include <memory>
#include <cstring> // memcpy
#include "../threads/TestCollision.h"
namespace tjp {
namespace core {
template<typename T, int N>
struct FilledArray : StackArray<T, N>
{
using Super = StackArray<T, N>;
using iterator = typename Super::iterator;
using const_iterator = typename Super::const_iterator;
void insert(const T &element)
{
this->push_back(element);
}
void erase (typename Super::iterator i)
{
if (i == this->end())
return;
auto &back = this->back();
if (i != &back)
*i = std::move(back);
this->pop_back();
}
void erase (const T &element)
{
erase(find(element));
}
iterator find (const T &element)
{
// now iterator all except for what used to be the end element
for (auto i=this->begin(); i!=this->end(); ++i)
{
if (*i == element)
{
// the end element was the last element
return i;
}
}
return this->end();
}
} ;
} // namespace utilities
} // namespace