Changeset 35144 in webkit for trunk/JavaScriptCore/wtf
- Timestamp:
- Jul 11, 2008, 7:24:25 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/ListHashSet.h
r30356 r35144 35 35 // in which they are added. 36 36 37 // In theory it would be possible to add prepend, insertAfter , insertBefore,37 // In theory it would be possible to add prepend, insertAfter 38 38 // and an append that moves the element to the end even if already present, 39 39 // but unclear yet if these are needed. … … 92 92 bool contains(const ValueType&) const; 93 93 94 // the return value is a pair of an i nterator to the new value's location,94 // the return value is a pair of an iterator to the new value's location, 95 95 // and a bool that is true if an new entry was added 96 96 pair<iterator, bool> add(const ValueType&); 97 98 pair<iterator, bool> insertBefore(const ValueType& beforeValue, const ValueType& newValue); 99 pair<iterator, bool> insertBefore(iterator it, const ValueType&); 97 100 98 101 void remove(const ValueType&); … … 103 106 void unlinkAndDelete(Node*); 104 107 void appendNode(Node*); 108 void insertNodeBefore(Node* beforeNode, Node* newNode); 105 109 void deleteAllNodes(); 106 110 iterator makeIterator(Node*); … … 470 474 471 475 template<typename T, typename U> 476 pair<typename ListHashSet<T, U>::iterator, bool> ListHashSet<T, U>::insertBefore(iterator it, const ValueType& newValue) 477 { 478 typedef ListHashSetTranslator<ValueType, HashFunctions> Translator; 479 pair<typename ImplType::iterator, bool> result = m_impl.template add<ValueType, NodeAllocator*, Translator>(newValue, m_allocator.get()); 480 if (result.second) 481 insertNodeBefore(it.node(), *result.first); 482 return std::make_pair(makeIterator(*result.first), result.second); 483 484 } 485 486 template<typename T, typename U> 487 pair<typename ListHashSet<T, U>::iterator, bool> ListHashSet<T, U>::insertBefore(const ValueType& beforeValue, const ValueType& newValue) 488 { 489 insertBefore(find(beforeValue), newValue); 490 } 491 492 template<typename T, typename U> 472 493 inline void ListHashSet<T, U>::remove(iterator it) 473 494 { … … 533 554 534 555 template<typename T, typename U> 556 void ListHashSet<T, U>::insertNodeBefore(Node* beforeNode, Node* newNode) 557 { 558 if (!beforeNode) 559 return appendNode(newNode); 560 561 newNode->m_next = beforeNode; 562 newNode->m_prev = beforeNode->m_prev; 563 if (beforeNode->m_prev) 564 beforeNode->m_prev->m_next = newNode; 565 beforeNode->m_prev = newNode; 566 567 if (!newNode->m_prev) 568 m_head = newNode; 569 } 570 571 template<typename T, typename U> 535 572 void ListHashSet<T, U>::deleteAllNodes() 536 573 {
Note:
See TracChangeset
for help on using the changeset viewer.