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

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

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/list.h ('k') | src/liveobjectlist.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 template <typename T> 210 template <typename T>
211 int SortedListBSearch( 211 int SortedListBSearch(
212 const List<T>& list, T elem, int (*cmp)(const T* x, const T* y)) { 212 const List<T>& list, T elem, int (*cmp)(const T* x, const T* y)) {
213 int low = 0; 213 int low = 0;
214 int high = list.length() - 1; 214 int high = list.length() - 1;
215 while (low <= high) { 215 while (low <= high) {
216 int mid = (low + high) / 2; 216 int mid = (low + high) / 2;
217 T mid_elem = list[mid]; 217 T mid_elem = list[mid];
218 218
219 if (mid_elem > elem) { 219 if (cmp(&mid_elem, &elem) > 0) {
220 high = mid - 1; 220 high = mid - 1;
221 continue; 221 continue;
222 } 222 }
223 if (mid_elem < elem) { 223 if (cmp(&mid_elem, &elem) < 0) {
224 low = mid + 1; 224 low = mid + 1;
225 continue; 225 continue;
226 } 226 }
227 // Found the elememt. 227 // Found the elememt.
228 return mid; 228 return mid;
229 } 229 }
230 return -1; 230 return -1;
231 } 231 }
232 232
233 233
234 template <typename T> 234 template <typename T>
235 int SortedListBSearch(const List<T>& list, T elem) { 235 int SortedListBSearch(const List<T>& list, T elem) {
236 return SortedListBSearch<T>(list, elem, PointerValueCompare<T>); 236 return SortedListBSearch<T>(list, elem, PointerValueCompare<T>);
237 } 237 }
238 238
239
239 } } // namespace v8::internal 240 } } // namespace v8::internal
240 241
241 #endif // V8_LIST_INL_H_ 242 #endif // V8_LIST_INL_H_
OLDNEW
« no previous file with comments | « src/list.h ('k') | src/liveobjectlist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698