make expanding buffer externally expandable with copy!
parent
5ab01e43df
commit
f99e6b3db9
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.20)
|
||||
include(cmake/color.cmake)
|
||||
|
||||
set(BLT_VERSION 0.18.14)
|
||||
set(BLT_VERSION 0.18.15)
|
||||
set(BLT_TEST_VERSION 0.0.1)
|
||||
|
||||
set(BLT_TARGET BLT)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-1" target="_DS3495almi1g_SXSTfi-3">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-1" target="_DS3495almi1g_SXSTfi-3">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="440" y="240" />
|
||||
|
@ -12,7 +12,7 @@
|
|||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-1" target="_DS3495almi1g_SXSTfi-2">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-1" target="_DS3495almi1g_SXSTfi-2">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="440" y="240" />
|
||||
|
@ -23,25 +23,25 @@
|
|||
<mxCell id="_DS3495almi1g_SXSTfi-1" value="<div><p style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;"><span style="background-color: rgb(255, 248, 247);">arg_data_t</span></p></div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="380" y="130" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-2" target="_DS3495almi1g_SXSTfi-5">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-15" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-2" target="_DS3495almi1g_SXSTfi-5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-2" value="<div><pre style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;"><font style="background-color: rgb(252, 245, 245);" color="#030303">arg_data_vec_t</font></pre></div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="280" width="150" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-6">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-6">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-7">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-7">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-9">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-3" target="_DS3495almi1g_SXSTfi-9">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-3" value="<div><pre style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;"><font style="background-color: rgb(255, 248, 247);" color="#030303">arg_data_internal_t</font></pre></div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="280" width="160" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-5" target="_DS3495almi1g_SXSTfi-19">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-5" target="_DS3495almi1g_SXSTfi-19">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-5" value="<pre style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;">std::vector&lt;arg_data_internal_t&gt;</pre>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
|
@ -56,13 +56,13 @@
|
|||
<mxCell id="_DS3495almi1g_SXSTfi-9" value="<div style="background-color: rgb(30, 31, 34);"><pre style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;"><span style="background-color: rgb(255, 248, 247);">int32_t</span></pre></div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
<mxGeometry x="320" y="440" width="120" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-20">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-20">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-21">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-21">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-22">
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-18" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge_t="1" parent="1" source="_DS3495almi1g_SXSTfi-19" target="_DS3495almi1g_SXSTfi-22">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="_DS3495almi1g_SXSTfi-19" value="<div style="background-color: rgb(30, 31, 34);"><pre style="font-family:'JetBrains Mono',monospace;font-size:9.8pt;"><span style="background-color: rgb(255, 248, 247);">arg_data_internal_t</span></pre></div>" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
|
||||
|
|
|
@ -376,14 +376,14 @@ namespace blt
|
|||
constexpr inline T& operator[](size_t index)
|
||||
{
|
||||
if (index >= size())
|
||||
expand(index);
|
||||
allocate_for(index);
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
constexpr inline const T& operator[](size_t index) const
|
||||
{
|
||||
if (index >= size())
|
||||
expand(index);
|
||||
allocate_for(index);
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
|
@ -461,13 +461,10 @@ namespace blt
|
|||
{
|
||||
delete_this(buffer_, size());
|
||||
}
|
||||
|
||||
private:
|
||||
void expand(blt::size_t size)
|
||||
|
||||
void expand(blt::size_t new_size)
|
||||
{
|
||||
size = std::max(size_, size);
|
||||
size = blt::mem::next_byte_allocation(size);
|
||||
T* new_buffer = new T[size];
|
||||
T* new_buffer = new T[new_size];
|
||||
if (buffer_ != nullptr)
|
||||
{
|
||||
if constexpr (std::is_trivially_copyable_v<T>)
|
||||
|
@ -486,7 +483,15 @@ namespace blt
|
|||
delete[] buffer_;
|
||||
}
|
||||
buffer_ = new_buffer;
|
||||
size_ = size;
|
||||
size_ = new_size;
|
||||
}
|
||||
|
||||
private:
|
||||
void allocate_for(blt::size_t accessing_index)
|
||||
{
|
||||
accessing_index = std::max(size_, accessing_index);
|
||||
accessing_index = blt::mem::next_byte_allocation(accessing_index);
|
||||
expand(accessing_index);
|
||||
}
|
||||
|
||||
inline void delete_this(T* buffer, blt::size_t)
|
||||
|
|
Loading…
Reference in New Issue