summaryrefslogtreecommitdiff
path: root/euler/include/vector
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2024-07-27 16:57:39 -0400
committerBenji Dial <benji@benjidial.net>2024-07-27 16:57:39 -0400
commitfbfc078e9f44c1c1e95c9c484f1d5650bcf631b7 (patch)
treecab539c8cbbac81d895b6f8be695f3f53bf8f4d5 /euler/include/vector
parent9af5588c30c4126a2800aae1afcb0de2c373dc6c (diff)
downloadhilbert-os-fbfc078e9f44c1c1e95c9c484f1d5650bcf631b7.tar.gz
lots and lots of userspace stuff
Diffstat (limited to 'euler/include/vector')
-rw-r--r--euler/include/vector61
1 files changed, 1 insertions, 60 deletions
diff --git a/euler/include/vector b/euler/include/vector
index f5083ed..2184475 100644
--- a/euler/include/vector
+++ b/euler/include/vector
@@ -1,62 +1,3 @@
#pragma once
-#include <stddef.h>
-#include <utility>
-
-namespace std {
-
- template <class t>
- class vector {
-
- t *buffer;
- size_t buffer_length;//always positive
- size_t count;
-
- public:
- vector() : buffer(new t[16]), buffer_length(16), count(0) {}
-
- ~vector() {
- delete[] buffer;
- }
-
- t &operator[](size_t pos) {
- return buffer[pos];
- }
-
- const t &operator[](size_t pos) const {
- return buffer[pos];
- }
-
- t *data() {
- return buffer;
- }
-
- const t *data() const {
- return buffer;
- }
-
- size_t size() const {
- return count;
- }
-
- void reserve(size_t new_length) {
- if (new_length <= buffer_length)
- return;
- t *new_buffer = new t[new_length];
- for (size_t i = 0; i < count; ++i)
- new_buffer[i] = std::move(buffer[i]);
- delete[] buffer;
- buffer = new_buffer;
- buffer_length = new_length;
- }
-
- void push_back(t &&value) {
- if (count == buffer_length)
- reserve(count * 2);
- buffer[count++] = std::move(value);
- }
-
- //TODO
- };
-
-}
+#include <std/vector.hpp>