template<typename ValueType, unsigned PageSize, typename PagerType, unsigned BlockSize, typename AllocStr, typename SizeType>
class stxxl::vector< ValueType, PageSize, PagerType, BlockSize, AllocStr, SizeType >
External vector container.
Introduction to vector container: see STXXL Vector tutorial.
Design and Internals of vector container: see Vector.
For semantics of the methods see documentation of the STL std::vector
- Template Parameters
-
ValueType | type of contained objects (POD with no references to internal memory) |
PageSize | number of blocks in a page |
PagerType | pager type, random_pager<x> or lru_pager<x> , where x is the default number of pages, default is lru_pager<8> |
BlockSize | external block size in bytes, default is 2 MiB |
AllocStr | one of allocation strategies: striping , RC , SR , or FR default is RC |
Memory consumption: BlockSize*x*PageSize bytes
- Warning
- Do not store references to the elements of an external vector. Such references might be invalidated during any following access to elements of the vector
- Examples:
- examples/algo/copy_and_sort_file.cpp, examples/algo/phonebills.cpp, examples/algo/phonebills_genlog.cpp, examples/algo/sort_file.cpp, examples/applications/skew3.cpp, examples/containers/copy_file.cpp, examples/containers/vector1.cpp, examples/containers/vector2.cpp, examples/containers/vector_buf.cpp, and examples/stream/stream1.cpp.
Definition at line 255 of file vector.h.
|
|
| vector (size_type n=0, unsigned_type npages=pager_type().size()) |
| Constructs external vector with n elements. More...
|
|
| vector (file *from, size_type size=size_type(-1), unsigned_type npages=pager_type().size()) |
| Construct vector from a file. More...
|
|
| vector (const vector &obj) |
| copy-constructor More...
|
|
| ~vector () |
|
|
void | swap (vector &obj) |
| swap content More...
|
|
|
void | allocate_page_cache () const |
| Allocate page cache, must be called to allow access to elements. More...
|
|
void | deallocate_page_cache () const |
| allows to free the cache, but you may not access any element until call allocate_page_cache() again More...
|
|
void | export_files (std::string filename_prefix) |
| Export data such that it is persistent on the file system. Resulting files will be numbered ascending. More...
|
|
file * | get_file () const |
| Get the file associated with this vector, or NULL. More...
|
|
|
size_type | size () const |
| return the size of the vector. More...
|
|
bool | empty () const |
| true if the vector's size is zero. More...
|
|
size_type | capacity () const |
| Return the number of elelemtsn for which external memory has been allocated. capacity() is always greator than or equal to size(). More...
|
|
size_type | raw_capacity () const |
| Returns the number of bytes that the vector has allocated on disks. More...
|
|
void | reserve (size_type n) |
| Reserves at least n elements in external memory. More...
|
|
void | resize (size_type n) |
| Resize vector contents to n items. More...
|
|
void | resize (size_type n, bool shrink_capacity) |
| Resize vector contents to n items, and allow the allocated external memory to shrink. Internal memory allocation remains unchanged. More...
|
|
|
void | clear () |
| Erases all of the elements and deallocates all external memory that is occupied. More...
|
|
void | flush () const |
| Flushes the cache pages to the external memory. More...
|
|
|
void | push_back (const_reference obj) |
| Append a new element at the end. More...
|
|
void | pop_back () |
| Removes the last element (without returning it, see back()). More...
|
|
|
reference | back () |
| Returns a reference to the last element, see More Notes. More...
|
|
reference | front () |
| Returns a reference to the first element, see More Notes. More...
|
|
const_reference | back () const |
| Returns a constant reference to the last element, see More Notes. More...
|
|
const_reference | front () const |
| Returns a constant reference to the first element, see More Notes. More...
|
|
vector & | operator= (const vector &obj) |
| assignment operator More...
|
|
|
iterator | begin () |
| returns an iterator pointing to the beginning of the vector, see More Notes. More...
|
|
const_iterator | begin () const |
| returns a const_iterator pointing to the beginning of the vector, see More Notes. More...
|
|
const_iterator | cbegin () const |
| returns a const_iterator pointing to the beginning of the vector, see More Notes. More...
|
|
iterator | end () |
| returns an iterator pointing beyond the end of the vector, see More Notes. More...
|
|
const_iterator | end () const |
| returns a const_iterator pointing beyond the end of the vector, see More Notes. More...
|
|
const_iterator | cend () const |
| returns a const_iterator pointing beyond the end of the vector, see More Notes. More...
|
|
reverse_iterator | rbegin () |
| returns a reverse_iterator pointing to the end of the vector. More...
|
|
const_reverse_iterator | rbegin () const |
| returns a reverse_iterator pointing to the end of the vector. More...
|
|
const_reverse_iterator | crbegin () const |
| returns a reverse_iterator pointing to the end of the vector. More...
|
|
reverse_iterator | rend () |
| returns a reverse_iterator pointing beyond the beginning of the vector. More...
|
|
const_reverse_iterator | rend () const |
| returns a reverse_iterator pointing beyond the beginning of the vector. More...
|
|
const_reverse_iterator | crend () const |
| returns a reverse_iterator pointing beyond the beginning of the vector. More...
|
|
|
reference | operator[] (size_type offset) |
| access the element at the given vector's offset More...
|
|
const_reference | operator[] (size_type offset) const |
| access the element at the given vector's offset More...
|
|
reference | at (size_type offset) |
| access the element at the given vector's offset More...
|
|
const_reference | at (size_type offset) const |
| access the element at the given vector's offset More...
|
|
bool | is_element_cached (size_type offset) const |
| return true if the given vector offset is in cache More...
|
|
|
template<typename ForwardIterator > |
void | set_content (const ForwardIterator &bid_begin, const ForwardIterator &bid_end, size_type n) |
| Set the blocks and the size of this container explicitly. The vector must be completely empty before. More...
|
|
unsigned_type | numpages () const |
| Number of pages used by the pager. More...
|
|
|
enum | constants { block_size = BlockSize,
page_size = PageSize,
on_disk = -1
} |
|
typedef ValueType | value_type |
| The type of elements stored in the vector. More...
|
|
typedef value_type & | reference |
| reference to value_type More...
|
|
typedef const value_type & | const_reference |
| constant reference to value_type More...
|
|
typedef value_type * | pointer |
| pointer to value_type More...
|
|
typedef const value_type * | const_pointer |
| constant pointer to value_type More...
|
|
typedef SizeType | size_type |
| an unsigned 64-bit integral type More...
|
|
typedef stxxl::int64 | difference_type |
|
typedef PagerType | pager_type |
|
typedef AllocStr | alloc_strategy_type |
|
typedef vector_iterator
< value_type,
alloc_strategy_type, size_type,
difference_type, block_size,
pager_type, page_size > | iterator |
| iterator used to iterate through a vector, see More Notes. More...
|
|
typedef const_vector_iterator
< value_type,
alloc_strategy_type, size_type,
difference_type, block_size,
pager_type, page_size > | const_iterator |
| constant iterator used to iterate through a vector, see More Notes. More...
|
|
typedef std::reverse_iterator
< iterator > | reverse_iterator |
|
typedef std::reverse_iterator
< const_iterator > | const_reverse_iterator |
|
template<typename ValueType, unsigned PageSize, typename PagerType, unsigned BlockSize, typename AllocStr, typename SizeType>
Reserves at least n elements in external memory.
If n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional external memory. If the request is successful, then capacity() is greater than or equal to n; otherwise capacity() is unchanged. In either case, size() is unchanged.
Definition at line 1057 of file vector.h.
template<typename ValueType, unsigned PageSize, typename PagerType, unsigned BlockSize, typename AllocStr, typename SizeType>
template<typename ForwardIterator >
void stxxl::vector< ValueType, PageSize, PagerType, BlockSize, AllocStr, SizeType >::set_content |
( |
const ForwardIterator & |
bid_begin, |
|
|
const ForwardIterator & |
bid_end, |
|
|
size_type |
n |
|
) |
| |
|
inline |
Set the blocks and the size of this container explicitly. The vector must be completely empty before.
Definition at line 1554 of file vector.h.