| OLD | NEW |
| 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 Loading... |
| 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(T& elm) { | 93 bool List<T, P>::Contains(const T& elm) { |
| 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)) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 ASSERT(capacity >= 0); | 117 ASSERT(capacity >= 0); |
| 118 data_ = (capacity > 0) ? NewData(capacity) : NULL; | 118 data_ = (capacity > 0) ? NewData(capacity) : NULL; |
| 119 capacity_ = capacity; | 119 capacity_ = capacity; |
| 120 length_ = 0; | 120 length_ = 0; |
| 121 } | 121 } |
| 122 | 122 |
| 123 | 123 |
| 124 } } // namespace v8::internal | 124 } } // namespace v8::internal |
| 125 | 125 |
| 126 #endif // V8_LIST_INL_H_ | 126 #endif // V8_LIST_INL_H_ |
| OLD | NEW |