/src/aspell/modules/speller/default/block_vector.hpp
Line | Count | Source |
1 | | // Copyright (c) 2000 |
2 | | // Kevin Atkinson |
3 | | // |
4 | | // Permission to use, copy, modify, distribute and sell this software |
5 | | // and its documentation for any purpose is hereby granted without |
6 | | // fee, provided that the above copyright notice appear in all copies |
7 | | // and that both that copyright notice and this permission notice |
8 | | // appear in supporting documentation. Kevin Atkinson makes no |
9 | | // representations about the suitability of this software for any |
10 | | // purpose. It is provided "as is" without express or implied |
11 | | // warranty. |
12 | | |
13 | | #ifndef __autil_block_vector__ |
14 | | #define __autil_block_vector__ |
15 | | |
16 | | #include <stddef.h> |
17 | | //#include <iterator> |
18 | | |
19 | | namespace aspeller { |
20 | | |
21 | | template <typename T> |
22 | | class BlockVector { |
23 | | T * begin_; |
24 | | T * end_; |
25 | | public: |
26 | | typedef T value_type; |
27 | | typedef size_t size_type; |
28 | | typedef ptrdiff_t difference_type; |
29 | | typedef T * iterator; |
30 | | typedef T * const_iterator; |
31 | | typedef T & reference; |
32 | | typedef const T & const_reference; |
33 | | typedef T * pointer; |
34 | | typedef T * const_pointer; |
35 | | //typedef std::random_access_iterator_tag iterator_category; |
36 | | typedef ptrdiff_t distance_type; |
37 | | |
38 | | BlockVector() : begin_(0), end_(0) {} |
39 | 1.44k | BlockVector(size_type) : begin_(0), end_(0) {} // noop |
40 | | BlockVector(T * b, T * e) : begin_(b), end_(e) {} |
41 | 1.44k | void set(T * b, T * e) {begin_ = b; end_ = e;} |
42 | 1.44k | iterator begin() {return begin_;} |
43 | 1.44k | iterator end() {return end_;} |
44 | 226k | const_iterator begin() const {return begin_;} |
45 | 15.0M | const_iterator end() const {return end_;} |
46 | 44.5M | size_type size() const {return end_ - begin_;} |
47 | | bool empty() const {return begin_ != end_;} |
48 | | reference operator[](size_type i) {return *(begin_ + i);} |
49 | 74.0M | const_reference operator[](size_type i) const {return *(begin_ + i);} |
50 | | }; |
51 | | |
52 | | } |
53 | | |
54 | | #endif |