diff options
| author | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
| commit | 06115dd49dca2f8eb5f14606437e8fd20037cc4d (patch) | |
| tree | 5ec4bca6158319b3f5285d7689c5f94ae8da8c93 /src/base/tl | |
| parent | 63e059b8fff6498e42b765a1dca000e53005ea77 (diff) | |
| download | zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.tar.gz zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.zip | |
added "Whitespace and line Endings cleanup" by GreYFoX
Diffstat (limited to 'src/base/tl')
| -rw-r--r-- | src/base/tl/algorithm.h | 14 | ||||
| -rw-r--r-- | src/base/tl/array.h | 44 | ||||
| -rw-r--r-- | src/base/tl/range.h | 46 | ||||
| -rw-r--r-- | src/base/tl/sorted_array.h | 8 | ||||
| -rw-r--r-- | src/base/tl/string.h | 20 |
5 files changed, 66 insertions, 66 deletions
diff --git a/src/base/tl/algorithm.h b/src/base/tl/algorithm.h index c5cd74c3..6b2e542a 100644 --- a/src/base/tl/algorithm.h +++ b/src/base/tl/algorithm.h @@ -8,7 +8,7 @@ /* insert 4 - v + v 1 2 3 4 5 6 */ @@ -38,12 +38,12 @@ R partition_binary(R range, T value) concept_size::check(range); concept_slice::check(range); concept_sorted::check(range); - + if(range.empty()) return range; if(range.back() < value) return R(); - + while(range.size() > 1) { unsigned pivot = (range.size()-1)/2; @@ -82,7 +82,7 @@ void sort_bubble(R range) concept_empty::check(range); concept_forwarditeration::check(range); concept_backwarditeration::check(range); - + // slow bubblesort :/ for(; !range.empty(); range.pop_back()) { @@ -119,18 +119,18 @@ bool sort_verify(R range) { concept_empty::check(range); concept_forwarditeration::check(range); - + typename R::type *prev = &range.front(); range.pop_front(); for(; !range.empty(); range.pop_front()) { typename R::type *cur = &range.front(); - + if(*cur < *prev) return false; prev = cur; } - + return true; } diff --git a/src/base/tl/array.h b/src/base/tl/array.h index 0cee2afc..4f4b2fc3 100644 --- a/src/base/tl/array.h +++ b/src/base/tl/array.h @@ -10,10 +10,10 @@ /* Class: array Normal dynamic array class - + Remarks: - Grows 50% each time it needs to fit new items - - Use set_size() if you know how many elements + - Use set_size() if you know how many elements - Use optimize() to reduce the needed space. */ template <class T, class ALLOCATOR = allocator_default<T> > @@ -24,7 +24,7 @@ class array : private ALLOCATOR list = 0x0; clear(); } - + public: typedef plain_range<T> range; @@ -35,7 +35,7 @@ public: { init(); } - + /* Function: array copy constructor */ @@ -60,7 +60,7 @@ public: /* Function: delete_all - + Remarks: - Invalidates ranges */ @@ -74,7 +74,7 @@ public: /* Function: clear - + Remarks: - Invalidates ranges */ @@ -124,7 +124,7 @@ public: /* Function: remove_index - + Remarks: - Invalidates ranges */ @@ -132,7 +132,7 @@ public: { for(int i = index+1; i < num_elements; i++) list[i-1] = list[i]; - + set_size(size()-1); } @@ -156,10 +156,10 @@ public: /* Function: add Adds an item to the array. - + Arguments: item - Item to add. - + Remarks: - Invalidates ranges - See remarks about <array> how the array grows. @@ -175,9 +175,9 @@ public: /* Function: insert Inserts an item into the array at a specified location. - + Arguments: - item - Item to insert. + item - Item to insert. r - Range where to insert the item Remarks: @@ -188,16 +188,16 @@ public: { if(r.empty()) return add(item); - + int index = (int)(&r.front()-list); incsize(); set_size(size()+1); - + for(int i = num_elements-1; i > index; i--) list[i] = list[i-1]; list[index] = item; - + return num_elements-1; } @@ -236,7 +236,7 @@ public: /* Function: set_size Resizes the array to the specified size. - + Arguments: new_size - The new size for the array. */ @@ -251,10 +251,10 @@ public: Function: hint_size Allocates the number of elements wanted but does not increase the list size. - + Arguments: hint - Size to allocate. - + Remarks: - If the hint is smaller then the number of elements, nothing will be done. - Invalidates ranges @@ -302,7 +302,7 @@ public: (*this)[i] = other[i]; return *this; } - + /* Function: all Returns a range that contains the whole array. @@ -318,18 +318,18 @@ protected: alloc(list_size+1); else alloc(list_size+list_size/2); - } + } } void alloc(int new_len) { list_size = new_len; T *new_list = ALLOCATOR::alloc_array(list_size); - + int end = num_elements < list_size ? num_elements : list_size; for(int i = 0; i < end; i++) new_list[i] = list[i]; - + ALLOCATOR::free_array(list); num_elements = num_elements < list_size ? num_elements : list_size; diff --git a/src/base/tl/range.h b/src/base/tl/range.h index 25047d31..f05169fa 100644 --- a/src/base/tl/range.h +++ b/src/base/tl/range.h @@ -11,7 +11,7 @@ /* Concept: concept_empty - + template<class T> struct range { @@ -25,7 +25,7 @@ struct concept_empty /* Concept: concept_index - + template<class T> struct range { @@ -39,7 +39,7 @@ struct concept_index /* Concept: concept_size - + template<class T> struct range { @@ -53,7 +53,7 @@ struct concept_size /* Concept: concept_slice - + template<class T> struct range { @@ -67,7 +67,7 @@ struct concept_slice /* Concept: concept_sorted - + template<class T> struct range { @@ -82,13 +82,13 @@ struct concept_sorted /* Concept: concept_forwarditeration Checks for the front and pop_front methods - + template<class T> struct range { void pop_front(); T &front() const; - }; + }; */ struct concept_forwarditeration { @@ -98,13 +98,13 @@ struct concept_forwarditeration /* Concept: concept_backwarditeration Checks for the back and pop_back methods - + template<class T> struct range { void pop_back(); T &back() const; - }; + }; */ struct concept_backwarditeration { @@ -119,7 +119,7 @@ struct concept_backwarditeration /* Class: plain_range - + Concepts: <concept_empty> <concept_index> @@ -142,13 +142,13 @@ public: { *this = r; } - + plain_range(T *b, T *e) { begin = b; end = e; } - + bool empty() const { return begin >= end; } void pop_front() { assert(!empty()); begin++; } void pop_back() { assert(!empty()); end--; } @@ -160,7 +160,7 @@ public: { return plain_range(begin+startindex, begin+endindex); } - + protected: T *begin; T *end; @@ -168,7 +168,7 @@ protected: /* Class: plain_range_sorted - + Concepts: Same as <plain_range> but with these additions: <concept_sorted> @@ -180,7 +180,7 @@ class plain_range_sorted : public plain_range<T> public: /* sorted concept */ void sorted() const { } - + plain_range_sorted() {} @@ -188,11 +188,11 @@ public: { *this = r; } - + plain_range_sorted(T *b, T *e) : parent(b, e) {} - + plain_range_sorted slice(unsigned start, unsigned count) { return plain_range_sorted(parent::begin+start, parent::begin+start+count); @@ -206,29 +206,29 @@ private: reverse_range() {} public: typedef typename R::type type; - + reverse_range(R r) { range = r; } - + reverse_range(const reverse_range &other) { range = other.range; } - + bool empty() const { return range.empty(); } void pop_front() { range.pop_back(); } void pop_back() { range.pop_front(); } type& front() { return range.back(); } type& back() { return range.front(); } - + R range; }; template<class R> reverse_range<R> reverse(R range) { - return reverse_range<R>(range); + return reverse_range<R>(range); } template<class R> R reverse(reverse_range<R> range) { - return range.range; + return range.range; } #endif // TL_FILE_RANGE_HPP diff --git a/src/base/tl/sorted_array.h b/src/base/tl/sorted_array.h index 94ccd543..7e312e1e 100644 --- a/src/base/tl/sorted_array.h +++ b/src/base/tl/sorted_array.h @@ -10,11 +10,11 @@ template <class T, class ALLOCATOR = allocator_default<T> > class sorted_array : public array<T, ALLOCATOR> { typedef array<T, ALLOCATOR> parent; - + // insert and size is not allowed int insert(const T& item, typename parent::range r) { dbg_break(); return 0; } int set_size(int new_size) { dbg_break(); return 0; } - + public: typedef plain_range_sorted<T> range; @@ -27,7 +27,7 @@ public: { return parent::add(item); } - + void sort_range() { sort(all()); @@ -37,7 +37,7 @@ public: /* Function: all Returns a sorted range that contains the whole array. - */ + */ range all() { return range(parent::list, parent::list+parent::num_elements); } }; diff --git a/src/base/tl/string.h b/src/base/tl/string.h index 18fab4d4..e0b891ad 100644 --- a/src/base/tl/string.h +++ b/src/base/tl/string.h @@ -11,38 +11,38 @@ class string_base : private ALLOCATOR { char *str; int length; - + void reset() { str = 0; length = 0; } - + void free() { ALLOCATOR::free_array(str); reset(); - } - + } + void copy(const char *other_str, int other_length) { length = other_length; str = ALLOCATOR::alloc_array(length+1); mem_copy(str, other_str, length+1); } - + void copy(const string_base &other) { if(!other.str) return; copy(other.str, other.length); } - + public: string_base() { reset(); } string_base(const char *other_str) { copy(other_str, str_length(other_str)); } string_base(const string_base &other) { reset(); copy(other); } ~string_base() { free(); } - + string_base &operator = (const char *other) { free(); @@ -50,17 +50,17 @@ public: copy(other, str_length(other)); return *this; } - + string_base &operator = (const string_base &other) { free(); copy(other); return *this; } - + bool operator < (const char *other_str) const { return str_comp(str, other_str) < 0; } operator const char *() const { return str; } - + const char *cstr() const { return str; } }; |