47 const size_t start,
const size_t end);
48 array_t<T>(
const int fdes,
const off_t begin,
const off_t end);
49 array_t<T>(
const char *fn,
const off_t begin,
const off_t end);
51 const off_t begin,
const off_t end);
59 T* begin() {
return m_begin;};
60 T* end() {
return m_end;};
61 T& front() {
return *m_begin;};
62 T& back() {
return m_end[-1];};
63 const T* begin()
const {
return m_begin;};
64 const T* end()
const {
return m_end;};
65 const T& front()
const {
return *m_begin;};
66 const T& back()
const {
return m_end[-1];};
68 bool empty()
const {
return (m_begin == 0 || m_begin >= m_end);};
70 return (m_begin > 0 && m_end > m_begin ? m_end - m_begin : 0);
78 void truncate(
size_t keep,
size_t start);
87 size_t find(
const T&)
const;
111 iterator insert(iterator pos,
const T& val);
112 void insert(iterator p,
size_t n,
const T& val);
113 void insert(iterator p, const_iterator i, const_iterator j);
116 iterator erase(iterator p);
117 iterator erase(iterator i, iterator j);
120 void read(
const char*);
121 off_t
read(
const char*,
const off_t,
const off_t);
122 off_t
read(
const int,
const off_t,
const off_t);
123 int write(
const char*)
const;
124 int write(FILE* fptr)
const;
128 void print(std::ostream& out)
const;
159 uint32_t back)
const;
166 uint32_t lvl=0)
const;
172 #if defined(DEBUG) || defined(_DEBUG)
173 LOGGER(ibis::gVerbose > 10)
174 <<
"array_t::clear -- (" <<
static_cast<const void*
>(
this) <<
", "
175 << static_cast<const void*>(m_begin) <<
") resets m_end from "
176 <<
static_cast<const void*
>(m_end) <<
" to "
177 << static_cast<const void*>(m_begin);
189 rhs.m_begin = m_begin;
205 if (actual != 0 && actual->filename() == 0 &&
206 (
char*)(m_end+1) <= actual->end()) {
212 const difference_type nold = (m_end > m_begin ? m_end - m_begin : 0);
213 if (nold > 0x7FFFFFFE) {
214 throw "array_t must have less than 2^31 elements";
216 if (actual == 0 || actual->filename() != 0 ||
217 (
const T*)actual->end() <= m_end) {
218 size_t nnew = (nold >= 7 ? nold : 7) + nold;
219 if (nnew > 0x7FFFFFFFU)
223 if (actual != 0 && actual->filename() == 0 &&
224 (
char*)(m_end+1) <= actual->end()) {
230 throw "array_t failed to acquire the necessary memory space";
238 return (actual!=0 ? (
const T*)actual->end()-m_begin :
239 m_end>=m_begin ? m_end-m_begin : 0);
241 #endif // IBIS_ARRAY_T_H
std::ptrdiff_t difference_type
!< For array size.
Definition: array_t.h:34
Defines a simple file manager.
T * pointer
!< Const iterator type.
Definition: array_t.h:28
size_t size() const
Definition: array_t.h:69
const T & const_reference
!< Reference to a value.
Definition: array_t.h:31
bool equal_to(const array_t< T > &) const
Does this array have the same content as the other? Return true is yes, otherwise false...
Definition: array_t.cpp:820
void clear()
Reset the size to zero.
Definition: array_t.h:171
void sort(array_t< uint32_t > &ind) const
Produce index for ascending order.
Definition: array_t.cpp:944
The storage class treats all memory as char*.
Definition: fileManager.h:237
void nosharing()
Make a non-shared copy of the array.
Definition: array_t.cpp:423
void swap(array_t< T > &rhs)
Swap the content of two array_t objects.
Definition: array_t.h:184
void stableSort(array_t< T > &tmp)
A stable sort using the provided workspace.
Definition: array_t.cpp:564
void read(const char *)
Read an array from the name file.
Definition: array_t.cpp:1764
void printStatus(std::ostream &out) const
Print internal pointer addresses.
Definition: array_t.cpp:1870
void push_back(const T &elm)
Add one element from the back.
Definition: array_t.h:204
void truncate(size_t keep, size_t start)
Replace the current array with nnew rows.
Definition: array_t.cpp:1436
T & reference
!< Pointer to a constant value.
Definition: array_t.h:30
int write(const char *) const
Write the content of array to the named file.
Definition: array_t.cpp:1823
size_t find(const T &) const
Find the first position where the value is no less than val.
Definition: array_t.cpp:507
void copy(const array_t< T > &rhs)
The copy function. It performs a shallow copy.
Definition: array_t.cpp:365
size_t capacity() const
The maximum number of elements can be stored with the current memory.
Definition: array_t.h:237
bool isSorted() const
Verify the values are in ascending order.
Definition: array_t.cpp:831
Template array_t is a replacement of std::vector.
Definition: array_t.h:24
size_t find_upper(const T &) const
Find the first position where the value is greater than val.
Definition: array_t.cpp:537
void resize(size_t n)
Change the size of the array to have elements.
Definition: array_t.cpp:1469
void deduplicate()
Remove the duplicate values.
Definition: array_t.cpp:903
T & operator[](size_t i)
Modifiable reference to an element of the array.
Definition: array_t.h:106
const T * const_iterator
!< Iterator type.
Definition: array_t.h:27
bool incore() const
Is the content of the array solely in memory?
Definition: array_t.h:109
size_t size_type
!< Type of values.
Definition: array_t.h:33
T * release()
Release the memory under management to the caller as a raw pointer.
Definition: array_t.cpp:1560
void deepCopy(const array_t< T > &rhs)
The deep copy function.
Definition: array_t.cpp:382
void pop_back()
Remove the last element.
Definition: array_t.h:75
void topk(uint32_t k, array_t< uint32_t > &ind) const
Return the positions of the k largest elements.
Definition: array_t.cpp:985
void reserve(size_t n)
Increase the size of the array_t to have the capacity to store at least n elements.
Definition: array_t.cpp:1509
const char * filename() const
Pointer to the file name supporting this storage object.
Definition: fileManager.h:253
array_t< T > & operator=(const array_t< T > &rhs)
Assignment operator. It performs a shallow copy.
Definition: array_t.cpp:349
T value_type
!< Reference to a constant value.
Definition: array_t.h:32
void bottomk(uint32_t k, array_t< uint32_t > &ind) const
Return the positions of the k smallest elements.
Definition: array_t.cpp:1047
void print(std::ostream &out) const
Print out the content of the array to the given output stream.
Definition: array_t.cpp:1886
ibis::fileManager::storage * getStorage()
Export the actual storage object.
Definition: array_t.h:139
const T & operator[](size_t i) const
Non-modifiable reference to an element of the array.
Definition: array_t.h:101
const T * const_pointer
!< Pointer to a value.
Definition: array_t.h:29