IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
collections
public
ice
container
resizable_container.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/container/container_concepts.hxx
>
6
7
namespace
ice::container
8
{
9
10
struct
ResizableContainer
11
{
12
template
<ice::concepts::ResizableContainer Self>
13
constexpr
bool
is_full
(
this
Self
const
& self)
noexcept
14
{
15
return
self.size() == self.capacity();
16
}
17
18
template
<ice::concepts::ResizableContainer Self>
19
constexpr
bool
not_full
(
this
Self
const
& self)
noexcept
20
{
21
return
self.size() < self.capacity();
22
}
23
24
template
<ice::concepts::ResizableContainer Self>
25
constexpr
void
reserve
(
this
Self& self,
ice::ncount
min_capacity)
noexcept
26
{
27
if
(self.capacity() < min_capacity)
28
{
29
self.set_capacity(min_capacity);
30
}
31
}
32
33
template
<ice::concepts::ResizableContainer Self>
34
constexpr
void
grow
(
this
Self& self,
ice::ncount
min_capacity =
ice::ncount_none
)
noexcept
35
{
36
ice::ncount
new_capacity = self.capacity() * 2 + 4;
37
if
(new_capacity < min_capacity)
38
{
39
new_capacity = min_capacity;
40
}
41
self.set_capacity(new_capacity);
42
}
43
44
template
<ice::concepts::ResizableContainer Self>
45
constexpr
void
shrink
(
this
Self& self)
noexcept
46
{
47
self.set_capacity(self.size());
48
}
49
};
50
51
}
// namespace ice
container_concepts.hxx
ice::container
Definition
associative_container.hxx:8
ice::ncount_none
static constexpr ice::ncount_invalid_t ncount_none
Definition
ncount.hxx:60
ice::container::ResizableContainer
Definition
resizable_container.hxx:11
ice::container::ResizableContainer::reserve
constexpr void reserve(this Self &self, ice::ncount min_capacity) noexcept
Definition
resizable_container.hxx:25
ice::container::ResizableContainer::is_full
constexpr bool is_full(this Self const &self) noexcept
Definition
resizable_container.hxx:13
ice::container::ResizableContainer::grow
constexpr void grow(this Self &self, ice::ncount min_capacity=ice::ncount_none) noexcept
Definition
resizable_container.hxx:34
ice::container::ResizableContainer::not_full
constexpr bool not_full(this Self const &self) noexcept
Definition
resizable_container.hxx:19
ice::container::ResizableContainer::shrink
constexpr void shrink(this Self &self) noexcept
Definition
resizable_container.hxx:45
ice::ncount
Definition
ncount.hxx:14
Generated by
1.18.0