FreeNOS
Container.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include "Container.h"
19 
21 {
22 }
23 
25 {
26 }
27 
28 bool Container::isEmpty() const
29 {
30  return count() == 0;
31 }
32 
34 {
35  if (this->size() > size)
36  return true;
37 
38  return resize(size);
39 }
40 
42 {
43  return resize(this->size() - size);
44 }
45 
47 {
48  return size();
49 }
50 
52 {
53  return false;
54 }
Container.h
Container::count
virtual Size count() const =0
Returns the number of items inside the Container.
Container::reserve
virtual bool reserve(Size size)
Ensure that at least the given size is available.
Definition: Container.cpp:33
Container::isEmpty
virtual bool isEmpty() const
Check if the Container is empty.
Definition: Container.cpp:28
Container::shrink
virtual bool shrink(Size size)
Shrink the container size by the given amount of items.
Definition: Container.cpp:41
Container::squeeze
virtual Size squeeze()
Try to minimize the memory required in the Container.
Definition: Container.cpp:46
Container::resize
virtual bool resize(Size size)
Change the size of the Container.
Definition: Container.cpp:51
Container::~Container
virtual ~Container()
Destructor.
Definition: Container.cpp:24
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
Container::Container
Container()
Constructor.
Definition: Container.cpp:20
Container::size
virtual Size size() const =0
Returns the maximum size of this Container.