| OLD | NEW |
| 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #ifndef SRC_SHARED_LIST_H_ | 5 #ifndef SRC_SHARED_LIST_H_ |
| 6 #define SRC_SHARED_LIST_H_ | 6 #define SRC_SHARED_LIST_H_ |
| 7 | 7 |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include "src/shared/assert.h" | 10 #include "src/shared/assert.h" |
| 11 | 11 |
| 12 namespace fletch { | 12 namespace dartino { |
| 13 | 13 |
| 14 // Lists are light-weight data structures that hold a sequence of | 14 // Lists are light-weight data structures that hold a sequence of |
| 15 // contiguous elements. List never take ownership of the data they | 15 // contiguous elements. List never take ownership of the data they |
| 16 // are passed in, so as long as the data is either in a zone or | 16 // are passed in, so as long as the data is either in a zone or |
| 17 // static, lists can be safely passed by value. | 17 // static, lists can be safely passed by value. |
| 18 template <typename T> | 18 template <typename T> |
| 19 class List { | 19 class List { |
| 20 public: | 20 public: |
| 21 List() : data_(NULL), length_(0) {} | 21 List() : data_(NULL), length_(0) {} |
| 22 | 22 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 free(data_); | 62 free(data_); |
| 63 data_ = NULL; | 63 data_ = NULL; |
| 64 length_ = 0; | 64 length_ = 0; |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 T* data_; | 68 T* data_; |
| 69 int length_; | 69 int length_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 } // namespace fletch | 72 } // namespace dartino |
| 73 | 73 |
| 74 #endif // SRC_SHARED_LIST_H_ | 74 #endif // SRC_SHARED_LIST_H_ |
| OLD | NEW |