• The first form returns the position of the first element in the range [beg,end) that is also in the
range [searchBeg,searchEnd).
• The second form returns the position of the first element in the range [beg,end) for which any
call
op(elem,searchElem)
with all elements of [searchBeg,searchEnd) yields true.
• Both forms return end if no matching elements are found.
• Note that op should not change its state during a function call. See Section 10.1.4, page 483, for
details.
• op should not modify the passed arguments.
• By using reverse iterators, you can find the last of several possible values.
• These algorithms were not part of the original STL.
• Before C++11, these algorithms required forward iterators instead of input iterators for the range
[beg,end).
• Complexity: linear (at most, numElems*numSearchElems comparisons or calls of op(), respectively).
The following example demonstrates the use of find_first_of():
•แบบฟอร์มแรกส่งกลับค่าตำแหน่งขององค์ประกอบแรกในช่วง [beg,end) ที่เป็นใน
ช่วง [searchBeg,searchEnd).
•แบบสองส่งกลับค่าตำแหน่งขององค์ประกอบแรกในช่วง [beg,end) ที่ใด ๆ
โทร
op (elem, searchElem)
มีองค์ประกอบทั้งหมดของ [searchBeg, searchEnd) ทำให้เป็นจริง
•รูปแบบกลับสิ้นสุดไม่มีองค์ประกอบที่ตรงกันอยู่
หมายเหตุ• op ที่ควรเปลี่ยนสถานะในระหว่างการเรียกฟังก์ชัน ดูส่วน 10.1.4 หน้า 483
รายละเอียด
• op ควรปรับเปลี่ยนการส่งผ่านอาร์กิวเมนต์ด้วย
•โดยย้อน iterators คุณสามารถค้นหาล่าสุดของหลายได้ค่า
•อัลกอริทึมเหล่านี้ไม่ได้เป็นส่วนหนึ่งของต้นฉบับ STL
•ก่อน C 11 เหล่านี้อัลกอริทึมต้องไปข้างหน้า iterators แทน iterators อินพุตสำหรับช่วง
[beg,end).
•ความซับซ้อน: เชิงเส้น (มากที่สุด numElems * numSearchElems เปรียบเทียบ หรือเรียกของ op() ตามลำดับ) .
ตัวอย่างต่อไปนี้สาธิตการใช้ find_first_of():
การแปล กรุณารอสักครู่..