Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: src/list-inl.h

Issue 10682: Inverted character classes (Closed)
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 for (int i = 0; i < length_; i++) { 94 for (int i = 0; i < length_; i++) {
95 if (data_[i] == elm) 95 if (data_[i] == elm)
96 return true; 96 return true;
97 } 97 }
98 return false; 98 return false;
99 } 99 }
100 100
101 101
102 template<typename T, class P> 102 template<typename T, class P>
103 void List<T, P>::Sort(int (*cmp)(const T* x, const T* y)) { 103 void List<T, P>::Sort(int (*cmp)(const T* x, const T* y)) {
104 qsort(data_, 104 ToVector().Sort(cmp);
105 length_,
106 sizeof(T),
107 reinterpret_cast<int (*)(const void*, const void*)>(cmp));
108 #ifdef DEBUG 105 #ifdef DEBUG
109 for (int i = 1; i < length_; i++) 106 for (int i = 1; i < length_; i++)
110 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0); 107 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0);
111 #endif 108 #endif
112 } 109 }
113 110
114 111
115 template<typename T, class P> 112 template<typename T, class P>
113 void List<T, P>::Sort() {
114 Sort(PointerSpaceship<T>);
115 }
116
117
118 template<typename T, class P>
116 void List<T, P>::Initialize(int capacity) { 119 void List<T, P>::Initialize(int capacity) {
117 ASSERT(capacity >= 0); 120 ASSERT(capacity >= 0);
118 data_ = (capacity > 0) ? NewData(capacity) : NULL; 121 data_ = (capacity > 0) ? NewData(capacity) : NULL;
119 capacity_ = capacity; 122 capacity_ = capacity;
120 length_ = 0; 123 length_ = 0;
121 } 124 }
122 125
123 126
124 } } // namespace v8::internal 127 } } // namespace v8::internal
125 128
126 #endif // V8_LIST_INL_H_ 129 #endif // V8_LIST_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698