Sux
Expandable.hpp
Go to the documentation of this file.
1 /*
2  * Sux: Succinct data structures
3  *
4  * Copyright (C) 2019-2020 Stefano Marchini and Sebastiano Vigna
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the Free
8  * Software Foundation; either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * This library is free software; you can redistribute it and/or modify it under
12  * the terms of the GNU General Public License as published by the Free Software
13  * Foundation; either version 3, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
16  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
18  *
19  * Under Section 7 of GPL version 3, you are granted additional permissions
20  * described in the GCC Runtime Library Exception, version 3.1, as published by
21  * the Free Software Foundation.
22  *
23  * You should have received a copy of the GNU General Public License and a copy of
24  * the GCC Runtime Library Exception along with this program; see the files
25  * COPYING3 and COPYING.RUNTIME respectively. If not, see
26  * <http://www.gnu.org/licenses/>.
27  */
28 
29 #pragma once
30 
31 #include "../support/common.hpp"
32 #include <assert.h>
33 #include <iostream>
34 #include <string>
35 #include <sys/mman.h>
36 
37 namespace sux::util {
38 
43 class Expandable {
44  public:
53  virtual void reserve(size_t capacity) = 0;
54 
64  virtual void grow(size_t capacity) = 0;
65 
74  virtual void resize(size_t size) = 0;
75 
77  virtual size_t size() const = 0;
78 
83  virtual void size(size_t size) = 0;
84 
90  virtual void trim(size_t capacity) = 0;
91 
93  void trimToFit() { trim(size()); };
94 };
95 
96 } // namespace sux::util
sux::util
Definition: Expandable.hpp:37
sux::util::Expandable::trimToFit
void trimToFit()
Definition: Expandable.hpp:93
sux::util::Expandable
Definition: Expandable.hpp:43
sux::util::Expandable::grow
virtual void grow(size_t capacity)=0
sux::util::Expandable::size
virtual size_t size() const =0
sux::util::Expandable::resize
virtual void resize(size_t size)=0
sux::util::Expandable::trim
virtual void trim(size_t capacity)=0
sux::util::Expandable::reserve
virtual void reserve(size_t capacity)=0