| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class DistributedNodes final { | 40 class DistributedNodes final { |
| 41 DISALLOW_NEW(); | 41 DISALLOW_NEW(); |
| 42 | 42 |
| 43 public: | 43 public: |
| 44 DistributedNodes() {} | 44 DistributedNodes() {} |
| 45 | 45 |
| 46 Node* first() const { return m_nodes.first(); } | 46 Node* first() const { return m_nodes.first(); } |
| 47 Node* last() const { return m_nodes.last(); } | 47 Node* last() const { return m_nodes.back(); } |
| 48 Node* at(size_t index) const { return m_nodes.at(index); } | 48 Node* at(size_t index) const { return m_nodes.at(index); } |
| 49 | 49 |
| 50 size_t size() const { return m_nodes.size(); } | 50 size_t size() const { return m_nodes.size(); } |
| 51 bool isEmpty() const { return m_nodes.isEmpty(); } | 51 bool isEmpty() const { return m_nodes.isEmpty(); } |
| 52 | 52 |
| 53 void append(Node*); | 53 void append(Node*); |
| 54 void clear() { | 54 void clear() { |
| 55 m_nodes.clear(); | 55 m_nodes.clear(); |
| 56 m_indices.clear(); | 56 m_indices.clear(); |
| 57 } | 57 } |
| 58 void shrinkToFit() { m_nodes.shrinkToFit(); } | 58 void shrinkToFit() { m_nodes.shrinkToFit(); } |
| 59 | 59 |
| 60 bool contains(const Node* node) const { return m_indices.contains(node); } | 60 bool contains(const Node* node) const { return m_indices.contains(node); } |
| 61 size_t find(const Node*) const; | 61 size_t find(const Node*) const; |
| 62 Node* nextTo(const Node*) const; | 62 Node* nextTo(const Node*) const; |
| 63 Node* previousTo(const Node*) const; | 63 Node* previousTo(const Node*) const; |
| 64 | 64 |
| 65 void swap(DistributedNodes& other); | 65 void swap(DistributedNodes& other); |
| 66 | 66 |
| 67 DECLARE_TRACE(); | 67 DECLARE_TRACE(); |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 HeapVector<Member<Node>> m_nodes; | 70 HeapVector<Member<Node>> m_nodes; |
| 71 HeapHashMap<Member<const Node>, size_t> m_indices; | 71 HeapHashMap<Member<const Node>, size_t> m_indices; |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 } // namespace blink | 74 } // namespace blink |
| 75 | 75 |
| 76 #endif | 76 #endif |
| OLD | NEW |