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

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

Issue 12427: Merge regexp2000 back into bleeding_edge (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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 | Annotate | Revision Log
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 84
85 85
86 template<typename T, class P> 86 template<typename T, class P>
87 void List<T, P>::Iterate(void (*callback)(T* x)) { 87 void List<T, P>::Iterate(void (*callback)(T* x)) {
88 for (int i = 0; i < length_; i++) callback(&data_[i]); 88 for (int i = 0; i < length_; i++) callback(&data_[i]);
89 } 89 }
90 90
91 91
92 template<typename T, class P> 92 template<typename T, class P>
93 bool List<T, P>::Contains(const T& elm) {
94 for (int i = 0; i < length_; i++) {
95 if (data_[i] == elm)
96 return true;
97 }
98 return false;
99 }
100
101
102 template<typename T, class P>
93 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)) {
94 qsort(data_, 104 ToVector().Sort(cmp);
95 length_,
96 sizeof(T),
97 reinterpret_cast<int (*)(const void*, const void*)>(cmp));
98 #ifdef DEBUG 105 #ifdef DEBUG
99 for (int i = 1; i < length_; i++) 106 for (int i = 1; i < length_; i++)
100 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0); 107 ASSERT(cmp(&data_[i - 1], &data_[i]) <= 0);
101 #endif 108 #endif
102 } 109 }
103 110
104 111
105 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>
106 void List<T, P>::Initialize(int capacity) { 119 void List<T, P>::Initialize(int capacity) {
107 ASSERT(capacity >= 0); 120 ASSERT(capacity >= 0);
108 data_ = (capacity > 0) ? NewData(capacity) : NULL; 121 data_ = (capacity > 0) ? NewData(capacity) : NULL;
109 capacity_ = capacity; 122 capacity_ = capacity;
110 length_ = 0; 123 length_ = 0;
111 } 124 }
112 125
113 126
114 } } // namespace v8::internal 127 } } // namespace v8::internal
115 128
116 #endif // V8_LIST_INL_H_ 129 #endif // V8_LIST_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698