aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Common/je_array.hpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-18 23:44:40 +0800
committerchai <chaifix@163.com>2018-11-18 23:44:40 +0800
commit8cb74178c2b8e5883a1181af687fa8cfc0c6e5da (patch)
treef56c536a029148df35bd4e82034a9b563a2381df /src/libjin/Common/je_array.hpp
parentf0f340dec7821cee103ab9267ef941a917ef4dc4 (diff)
*修改目录为小写
Diffstat (limited to 'src/libjin/Common/je_array.hpp')
-rw-r--r--src/libjin/Common/je_array.hpp123
1 files changed, 0 insertions, 123 deletions
diff --git a/src/libjin/Common/je_array.hpp b/src/libjin/Common/je_array.hpp
deleted file mode 100644
index 8a5cbf1..0000000
--- a/src/libjin/Common/je_array.hpp
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef __JE_COMMON_ARRAY_H__
-#define __JE_COMMON_ARRAY_H__
-
-namespace JinEngine
-{
-
- ///
- /// A array created on heap.
- ///
- template<typename T>
- class Array
- {
- public:
- ///
- /// Array constructor.
- ///
- Array()
- : length(0)
- , data(nullptr)
- {
- }
-
- ///
- /// Array constructor.
- ///
- /// @param l Length of array.
- ///
- Array(int l)
- {
- length = l;
- data = new T[l];
- }
-
- ///
- /// Array destructor.
- ///
- ~Array()
- {
- delete[] data;
- length = 0;
- }
-
- ///
- /// Get address of data.
- ///
- /// @return Address of data.
- ///
- T* operator &()
- {
- return data;
- }
-
- ///
- /// Get specific element of array.
- ///
- /// @return Element of array.
- ///
- T& operator[](int index)
- {
- return data[index];
- }
-
- ///
- /// Bind data with given data.
- ///
- /// @param data Data pointer.
- /// @param length Length of data.
- ///
- void bind(T* data, int length)
- {
- if (data != nullptr)
- delete data;
- this->data = data;
- this->length = length;
- }
-
- ///
- /// Add an element.
- ///
- /// @param v Value of element.
- ///
- void add(T value)
- {
- int len = length + 1;
- T* d = new T[len];
- memcpy(d, data, size());
- d[length] = value;
- bind(d, len);
- }
-
- ///
- /// Get size of data in byte.
- ///
- /// @return Size of data in byte.
- ///
- int size()
- {
- return sizeof(T) * length;
- }
-
- ///
- /// Get length of data.
- ///
- /// @return Count of data.
- ///
- int count()
- {
- return length;
- }
-
- private:
- // Disable new and delete.
- void* operator new(size_t t);
- void operator delete(void* ptr);
-
- T * data;
- unsigned int length;
-
- };
-
-} // namespace JinEngine
-
-#endif \ No newline at end of file