• The first form, available since C++11, shuffles the order of the elements in the range [beg,end), using an engine eng as introduced by the random numbers and distributions library (see Sec- tion 17.1.2, page 912). • The second form shuffles the order of the elements in the range [beg,end), using an implemen- tation-defined uniform distribution random-number generator, such as the C function rand(). • The third form shuffles the order of the elements in the range [beg,end), using op. op is called with an integral value of difference_type of the iterator: op(max) which should return a random number greater than or equal to zero and less than max. Thus, it should not return max itself. • For shuffle(), you should not pass an engine just temporarily created. See Section 17.1.1, page 911, for details. • Before C++11, op was declared as RandomFunc&, so you couldn’t pass a temporary value or an ordinary function. • Complexity: linear (numElems-1 swaps). NotethatoldglobalCfunctions,suchasrand(),storetheirlocalstatesinastaticvariable. However, thishassomedisadvantages: Forexample, therandom-numbergeneratorisinherentlythreadunsafe, andyoucan’thavetwoindependentstreamsofrandomnumbers. Therefore,functionobjectsprovide
•ฟอร์ม first ได้ตั้งแต่ C 11, shuffles ลำดับขององค์ประกอบในช่วง [วอน end), ใช้อังกฤษเป็นเครื่องมือที่นำมาใช้ โดยตัวเลขสุ่มและไลบรารีการกระจาย (ดูวินาทีสเตรชัน 17.1.2 หน้า 912) •แบบฟอร์ม shuffles สองลำดับขององค์ประกอบในช่วง [วอน end), ใช้การกำเนิดเลขสุ่มกระจายสม่ำเสมอเกี่ยว-tation-defined เช่น C ทำงาน rand() •ที่สามเป็น shuffles ลำดับขององค์ประกอบในช่วง [วอน end), ใช้ op. op เรียกว่า มีค่าเป็นของ difference_type ของตัวทำซ้ำ: op(max) ซึ่งควรกลับเป็นเลขสุ่มมากกว่า หรือเท่ากับศูนย์ และน้อยกว่าสูงสุด ดังนั้น มันควรกลับสูงสุดเอง •สำหรับ shuffle() คุณควรไม่ส่งเครื่องยนต์สร้างขึ้นเพียงชั่วคราว ดูส่วน 17.1.1, 911 หน้ารายละเอียด •ก่อน C 11, op ถูกประกาศเป็น RandomFunc& ดังนั้นคุณไม่สามารถส่งค่าชั่วคราวหรือมีฟังก์ชันที่ธรรมดา •ความซับซ้อน: เชิงเส้น (numElems-1 swaps) NotethatoldglobalCfunctions, storetheirlocalstatesinastaticvariable, suchasrand () อย่างไรก็ตาม thishassomedisadvantages: Forexample, therandom-numbergeneratorisinherentlythreadunsafe andyoucan'thavetwoindependentstreamsofrandomnumbers ดังนั้น functionobjectsprovide
การแปล กรุณารอสักครู่..
![](//thimg.ilovetranslation.com/pic/loading_3.gif?v=b9814dd30c1d7c59_8619)
•รูปแบบครั้งแรกที่มีตั้งแต่ C + +11, shuffles คำสั่งขององค์ประกอบในช่วง [ขอจบ) โดยใช้ eng เครื่องยนต์เป็นที่รู้จักโดยการสุ่มตัวเลขและห้องสมุดกระจาย (ดูวินาที-tion 17.1.2, หน้า 912) •รูปแบบที่สอง shuffles คำสั่งขององค์ประกอบในช่วง [ขอจบ) โดยใช้ implemen-ช่อกำหนดจำหน่ายชุดเครื่องกำเนิดไฟฟ้าแบบสุ่มจำนวนเช่น rand ฟังก์ชัน C () •รูปแบบที่สาม shuffles คำสั่งขององค์ประกอบในช่วง [ขอจบ) โดยใช้สหกรณ์ op เรียกว่ามีค่าหนึ่งของ difference_type ของ iterator: op (สูงสุด) ซึ่งควรจะกลับจำนวนสุ่มที่มากกว่าหรือเท่ากับศูนย์และน้อยกว่าค่าสูงสุด ดังนั้นจึงไม่ควรจะกลับตัวเองสูงสุด •สำหรับการสับเปลี่ยน () คุณไม่ควรส่งเครื่องยนต์ที่สร้างขึ้นเพียงชั่วคราว ดูมาตรา 17.1.1, หน้า 911 สำหรับรายละเอียด •ก่อน C + +11 สหกรณ์ได้รับการประกาศให้เป็น RandomFunc และดังนั้นคุณจึงไม่สามารถผ่านค่าชั่วคราวหรือฟังก์ชั่นธรรมดา •ซับซ้อน: เชิงเส้น (numElems-1 สัญญาแลกเปลี่ยน) NotethatoldglobalCfunctions, suchasrand () storetheirlocalstatesinastaticvariable แต่ thishassomedisadvantages: Forexample, Therandom-numbergeneratorisinherentlythreadunsafe, andyoucan'thavetwoindependentstreamsofrandomnumbers ดังนั้น functionobjectsprovide
การแปล กรุณารอสักครู่..
![](//thimg.ilovetranslation.com/pic/loading_3.gif?v=b9814dd30c1d7c59_8619)
- RST จึงฟอร์มใช้ได้ตั้งแต่ C 11 , shuf flและคำสั่งขององค์ประกอบในช่วง [ ขอร้อง จบ ) โดยใช้เครื่องมือ ENG เป็นแนะนำโดยตัวเลขสุ่มและการแจกแจงห้องสมุด ( ดูวินาที , 17.1.2 หน้า 912 ) - การ shuf 2 รูปแบบ flและคำสั่งขององค์ประกอบในช่วง [ ขอร้อง จบ ) , การใช้ implemen - tation de จึงเน็ดการแจกแจงเอกรูปจำนวนสุ่ม Generator ,เช่น C ฟังก์ชัน ( . - การ shuf รูปแบบที่สามflและคำสั่งขององค์ประกอบในช่วง [ ขอร้อง จบ ) ใช้ OP OP เรียกว่าที่มีมูลค่ารวมของ difference_type ของทำซ้ำ : OP ( max ) ซึ่งจะสุ่มตัวเลขที่มากกว่าหรือเท่ากับศูนย์ และน้อยกว่าแม็กซ์ ดังนั้น จึงไม่ควรกลับแม็กซ์นั่นเอง . - สำหรับ shuffle() , คุณไม่ควรผ่านเครื่องยนต์เพียงชั่วคราวที่สร้างขึ้นดูส่วน 17.1.1 หน้า 911 สำหรับรายละเอียด - ก่อนซี 11 ที่ถูกประกาศเป็น randomfunc & ดังนั้น คุณไม่สามารถส่งผ่านค่าชั่วคราวหรือฟังก์ชันธรรมดา - ความซับซ้อน : เชิงเส้น ( numelems-1 swaps ) notethatoldglobalcfunctions suchasrand() storetheirlocalstatesinastaticvariable , , . อย่างไรก็ตาม thishassomedisadvantages : การ numbergeneratorisinherentlythreadunsafe therandom ,andyoucan'thavetwoindependentstreamsofrandomnumbers . ดังนั้น functionobjectsprovide
การแปล กรุณารอสักครู่..
![](//thimg.ilovetranslation.com/pic/loading_3.gif?v=b9814dd30c1d7c59_8619)