| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 2 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DEFINE_INLINE_TRACE() { visitor->trace(m_nodes); } | 42 DEFINE_INLINE_TRACE() { visitor->trace(m_nodes); } |
| 43 | 43 |
| 44 size_t size() const { return m_nodes.size(); } | 44 size_t size() const { return m_nodes.size(); } |
| 45 bool isEmpty() const { return !m_nodes.size(); } | 45 bool isEmpty() const { return !m_nodes.size(); } |
| 46 Node* operator[](unsigned i) const { return m_nodes.at(i).get(); } | 46 Node* operator[](unsigned i) const { return m_nodes.at(i).get(); } |
| 47 void reserveCapacity(size_t newCapacity) { m_nodes.reserveCapacity(newCapaci
ty); } | 47 void reserveCapacity(size_t newCapacity) { m_nodes.reserveCapacity(newCapaci
ty); } |
| 48 void clear() { m_nodes.clear(); } | 48 void clear() { m_nodes.clear(); } |
| 49 void swap(NodeSet& other) { std::swap(m_isSorted, other.m_isSorted); std::sw
ap(m_subtreesAreDisjoint, other.m_subtreesAreDisjoint); m_nodes.swap(other.m_nod
es); } | 49 void swap(NodeSet& other) { std::swap(m_isSorted, other.m_isSorted); std::sw
ap(m_subtreesAreDisjoint, other.m_subtreesAreDisjoint); m_nodes.swap(other.m_nod
es); } |
| 50 | 50 |
| 51 // NodeSet itself does not verify that nodes in it are unique. | 51 // NodeSet itself does not verify that nodes in it are unique. |
| 52 void append(PassRefPtrWillBeRawPtr<Node> node) { m_nodes.append(node); } | 52 void append(RawPtr<Node> node) { m_nodes.append(node); } |
| 53 void append(const NodeSet& nodeSet) { m_nodes.appendVector(nodeSet.m_nodes);
} | 53 void append(const NodeSet& nodeSet) { m_nodes.appendVector(nodeSet.m_nodes);
} |
| 54 | 54 |
| 55 // Returns the set's first node in document order, or 0 if the set is empty. | 55 // Returns the set's first node in document order, or 0 if the set is empty. |
| 56 Node* firstNode() const; | 56 Node* firstNode() const; |
| 57 | 57 |
| 58 // Returns 0 if the set is empty. | 58 // Returns 0 if the set is empty. |
| 59 Node* anyNode() const; | 59 Node* anyNode() const; |
| 60 | 60 |
| 61 // NodeSet itself doesn't check if it contains nodes in document order - the | 61 // NodeSet itself doesn't check if it contains nodes in document order - the |
| 62 // caller should tell it if it does not. | 62 // caller should tell it if it does not. |
| 63 void markSorted(bool isSorted) { m_isSorted = isSorted; } | 63 void markSorted(bool isSorted) { m_isSorted = isSorted; } |
| 64 bool isSorted() const { return m_isSorted || m_nodes.size() < 2; } | 64 bool isSorted() const { return m_isSorted || m_nodes.size() < 2; } |
| 65 | 65 |
| 66 void sort() const; | 66 void sort() const; |
| 67 | 67 |
| 68 // No node in the set is ancestor of another. Unlike m_isSorted, this is | 68 // No node in the set is ancestor of another. Unlike m_isSorted, this is |
| 69 // assumed to be false, unless the caller sets it to true. | 69 // assumed to be false, unless the caller sets it to true. |
| 70 void markSubtreesDisjoint(bool disjoint) { m_subtreesAreDisjoint = disjoint;
} | 70 void markSubtreesDisjoint(bool disjoint) { m_subtreesAreDisjoint = disjoint;
} |
| 71 bool subtreesAreDisjoint() const { return m_subtreesAreDisjoint || m_nodes.s
ize() < 2; } | 71 bool subtreesAreDisjoint() const { return m_subtreesAreDisjoint || m_nodes.s
ize() < 2; } |
| 72 | 72 |
| 73 void reverse(); | 73 void reverse(); |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 NodeSet() : m_isSorted(true), m_subtreesAreDisjoint(false) { } | 76 NodeSet() : m_isSorted(true), m_subtreesAreDisjoint(false) { } |
| 77 void traversalSort() const; | 77 void traversalSort() const; |
| 78 | 78 |
| 79 bool m_isSorted; | 79 bool m_isSorted; |
| 80 bool m_subtreesAreDisjoint; | 80 bool m_subtreesAreDisjoint; |
| 81 WillBeHeapVector<RefPtrWillBeMember<Node>> m_nodes; | 81 HeapVector<Member<Node>> m_nodes; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace XPath | 84 } // namespace XPath |
| 85 | 85 |
| 86 } // namespace blink | 86 } // namespace blink |
| 87 #endif // XPathNodeSet_h | 87 #endif // XPathNodeSet_h |
| OLD | NEW |