Changeset 97825 in vbox
- Timestamp:
- Dec 16, 2022 2:40:21 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 154905
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/list.h
r97823 r97825 590 590 591 591 /** 592 * Applies a filter of type T to this list. 593 * 594 * @param other The list which contains the elements to filter out from this list. 595 * @return a reference to this list. 596 */ 597 RTCListBase<T, ITYPE, MT> &filter(const RTCListBase<T, ITYPE, MT> &other) 598 { 599 AssertReturn(this != &other, *this); 600 601 other.m_guard.enterRead(); 602 m_guard.enterWrite(); 603 604 for (size_t i = 0; i < m_cElements; i++) 605 { 606 for (size_t f = 0; f < other.m_cElements; f++) 607 { 608 if (RTCListHelper<T, ITYPE>::at(m_pArray, i) == RTCListHelper<T, ITYPE>::at(other.m_pArray, f)) 609 removeAtLocked(i); 610 } 611 } 612 613 m_guard.leaveWrite(); 614 other.m_guard.leaveRead(); 615 return *this; 616 } 617 618 /** 592 619 * Return the first item as constant object. 593 620 * -
trunk/src/VBox/Runtime/testcase/tstIprtMiniList.cpp
r97823 r97825 79 79 RTTESTI_CHECK(spList1 != spList4); 80 80 81 /* 82 * Test filtering. 83 */ 84 /* Basics. */ 85 RTCList<RTCString> spListFiltered; 86 spListFiltered.filter(RTCString("").split(",")); /* Empty filter. */ 87 /* String list. */ 88 spListFiltered = RTCString("filter-out1,filter-out2,foo").split(","); 89 spListFiltered.filter(RTCString("filter-out1,filter-out2").split(",")); 90 RTTESTI_CHECK(spListFiltered == RTCString("foo").split(",")); 91 /* Repeat. */ 92 spListFiltered.filter(RTCString("filter-out1,filter-out2").split(",")); 93 RTTESTI_CHECK(spListFiltered == RTCString("foo").split(",")); 94 RTTESTI_CHECK(spListFiltered != RTCString("bar").split(",")); 95 81 96 rcExit = RTTestSummaryAndDestroy(hTest); 82 97 }
Note:
See TracChangeset
for help on using the changeset viewer.