1、删除部分三方库

2、整合ylib为一个lib库
This commit is contained in:
xx
2024-05-26 12:51:32 +08:00
parent 4391d84402
commit ef63cfd6aa
9264 changed files with 24373 additions and 1648659 deletions

53
include/util/array.hpp Normal file
View File

@@ -0,0 +1,53 @@
#pragma once
#include <vector>
namespace ylib
{
template<typename T>
struct nolock_array
{
nolock_array() {
m_array = nullptr;
m_count = 0;
}
~nolock_array(){
free();
}
void free(){
if(m_array != nullptr)
delete[] m_array;
m_array = nullptr;
m_count = 0;
}
void init(const std::vector<T>& value){
if(value.size() == 0)
return;
m_array = new T[value.size()];
m_count = value.size();
for(size_t i=0;i<value.size();i++){
m_array[i] = value[i];
}
}
size_t append(const T& value){
std::vector<T> v;
v.resize(m_count+1);
for(size_t i=0;i<m_count;i++){
v[i] = m_array[i];
}
v[m_count] = value;
free();
init(v);
return m_count-1;
}
inline T get(size_t index){
if(index >= m_count){
printf("Unlocked array index is too long");
abort();
}
return m_array[index];
}
T* m_array;
size_t m_count;
};
}