aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Buffer.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/Buffer.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/Buffer.h')
-rw-r--r--Minecraft.World/Buffer.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/Minecraft.World/Buffer.h b/Minecraft.World/Buffer.h
new file mode 100644
index 00000000..1c66257b
--- /dev/null
+++ b/Minecraft.World/Buffer.h
@@ -0,0 +1,34 @@
+#pragma once
+
+//A buffer is a linear, finite sequence of elements of a specific primitive type. Aside from its content,
+//the essential properties of a buffer are its capacity, limit, and position:
+//
+//A buffer's capacity is the number of elements it contains. The capacity of a buffer is never negative and never changes.
+//
+//A buffer's limit is the index of the first element that should not be read or written.
+//A buffer's limit is never negative and is never greater than its capacity.
+//
+//A buffer's position is the index of the next element to be read or written.
+//A buffer's position is never negative and is never greater than its limit.
+class Buffer
+{
+protected:
+ const unsigned int m_capacity;
+ unsigned int m_position;
+ unsigned int m_limit;
+ unsigned int m_mark;
+ bool hasBackingArray;
+
+public:
+ Buffer( unsigned int capacity );
+ virtual ~Buffer() {}
+
+ Buffer *clear();
+ Buffer *limit(unsigned int newLimit);
+ unsigned int limit();
+ Buffer *position( unsigned int newPosition );
+ unsigned int position();
+ unsigned int remaining();
+
+ virtual Buffer *flip() = 0;
+}; \ No newline at end of file