MinMax.cs 118 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763
  1. using System;
  2. using System.Threading;
  3. using Cysharp.Threading.Tasks.Internal;
  4. namespace Cysharp.Threading.Tasks.Linq
  5. {
  6. public static partial class UniTaskAsyncEnumerable
  7. {
  8. public static UniTask<Int32> MinAsync(this IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken = default)
  9. {
  10. Error.ThrowArgumentNullException(source, nameof(source));
  11. return Min.MinAsync(source, cancellationToken);
  12. }
  13. public static UniTask<Int32> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default)
  14. {
  15. Error.ThrowArgumentNullException(source, nameof(source));
  16. Error.ThrowArgumentNullException(source, nameof(selector));
  17. return Min.MinAsync(source, selector, cancellationToken);
  18. }
  19. public static UniTask<Int32> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
  20. {
  21. Error.ThrowArgumentNullException(source, nameof(source));
  22. Error.ThrowArgumentNullException(source, nameof(selector));
  23. return Min.MinAwaitAsync(source, selector, cancellationToken);
  24. }
  25. public static UniTask<Int32> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
  26. {
  27. Error.ThrowArgumentNullException(source, nameof(source));
  28. Error.ThrowArgumentNullException(source, nameof(selector));
  29. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  30. }
  31. public static UniTask<Int64> MinAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default)
  32. {
  33. Error.ThrowArgumentNullException(source, nameof(source));
  34. return Min.MinAsync(source, cancellationToken);
  35. }
  36. public static UniTask<Int64> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default)
  37. {
  38. Error.ThrowArgumentNullException(source, nameof(source));
  39. Error.ThrowArgumentNullException(source, nameof(selector));
  40. return Min.MinAsync(source, selector, cancellationToken);
  41. }
  42. public static UniTask<Int64> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
  43. {
  44. Error.ThrowArgumentNullException(source, nameof(source));
  45. Error.ThrowArgumentNullException(source, nameof(selector));
  46. return Min.MinAwaitAsync(source, selector, cancellationToken);
  47. }
  48. public static UniTask<Int64> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
  49. {
  50. Error.ThrowArgumentNullException(source, nameof(source));
  51. Error.ThrowArgumentNullException(source, nameof(selector));
  52. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  53. }
  54. public static UniTask<Single> MinAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default)
  55. {
  56. Error.ThrowArgumentNullException(source, nameof(source));
  57. return Min.MinAsync(source, cancellationToken);
  58. }
  59. public static UniTask<Single> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default)
  60. {
  61. Error.ThrowArgumentNullException(source, nameof(source));
  62. Error.ThrowArgumentNullException(source, nameof(selector));
  63. return Min.MinAsync(source, selector, cancellationToken);
  64. }
  65. public static UniTask<Single> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default)
  66. {
  67. Error.ThrowArgumentNullException(source, nameof(source));
  68. Error.ThrowArgumentNullException(source, nameof(selector));
  69. return Min.MinAwaitAsync(source, selector, cancellationToken);
  70. }
  71. public static UniTask<Single> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default)
  72. {
  73. Error.ThrowArgumentNullException(source, nameof(source));
  74. Error.ThrowArgumentNullException(source, nameof(selector));
  75. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  76. }
  77. public static UniTask<Double> MinAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default)
  78. {
  79. Error.ThrowArgumentNullException(source, nameof(source));
  80. return Min.MinAsync(source, cancellationToken);
  81. }
  82. public static UniTask<Double> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default)
  83. {
  84. Error.ThrowArgumentNullException(source, nameof(source));
  85. Error.ThrowArgumentNullException(source, nameof(selector));
  86. return Min.MinAsync(source, selector, cancellationToken);
  87. }
  88. public static UniTask<Double> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default)
  89. {
  90. Error.ThrowArgumentNullException(source, nameof(source));
  91. Error.ThrowArgumentNullException(source, nameof(selector));
  92. return Min.MinAwaitAsync(source, selector, cancellationToken);
  93. }
  94. public static UniTask<Double> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default)
  95. {
  96. Error.ThrowArgumentNullException(source, nameof(source));
  97. Error.ThrowArgumentNullException(source, nameof(selector));
  98. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  99. }
  100. public static UniTask<Decimal> MinAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default)
  101. {
  102. Error.ThrowArgumentNullException(source, nameof(source));
  103. return Min.MinAsync(source, cancellationToken);
  104. }
  105. public static UniTask<Decimal> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default)
  106. {
  107. Error.ThrowArgumentNullException(source, nameof(source));
  108. Error.ThrowArgumentNullException(source, nameof(selector));
  109. return Min.MinAsync(source, selector, cancellationToken);
  110. }
  111. public static UniTask<Decimal> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
  112. {
  113. Error.ThrowArgumentNullException(source, nameof(source));
  114. Error.ThrowArgumentNullException(source, nameof(selector));
  115. return Min.MinAwaitAsync(source, selector, cancellationToken);
  116. }
  117. public static UniTask<Decimal> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
  118. {
  119. Error.ThrowArgumentNullException(source, nameof(source));
  120. Error.ThrowArgumentNullException(source, nameof(selector));
  121. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  122. }
  123. public static UniTask<Int32?> MinAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default)
  124. {
  125. Error.ThrowArgumentNullException(source, nameof(source));
  126. return Min.MinAsync(source, cancellationToken);
  127. }
  128. public static UniTask<Int32?> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default)
  129. {
  130. Error.ThrowArgumentNullException(source, nameof(source));
  131. Error.ThrowArgumentNullException(source, nameof(selector));
  132. return Min.MinAsync(source, selector, cancellationToken);
  133. }
  134. public static UniTask<Int32?> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
  135. {
  136. Error.ThrowArgumentNullException(source, nameof(source));
  137. Error.ThrowArgumentNullException(source, nameof(selector));
  138. return Min.MinAwaitAsync(source, selector, cancellationToken);
  139. }
  140. public static UniTask<Int32?> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
  141. {
  142. Error.ThrowArgumentNullException(source, nameof(source));
  143. Error.ThrowArgumentNullException(source, nameof(selector));
  144. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  145. }
  146. public static UniTask<Int64?> MinAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default)
  147. {
  148. Error.ThrowArgumentNullException(source, nameof(source));
  149. return Min.MinAsync(source, cancellationToken);
  150. }
  151. public static UniTask<Int64?> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default)
  152. {
  153. Error.ThrowArgumentNullException(source, nameof(source));
  154. Error.ThrowArgumentNullException(source, nameof(selector));
  155. return Min.MinAsync(source, selector, cancellationToken);
  156. }
  157. public static UniTask<Int64?> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
  158. {
  159. Error.ThrowArgumentNullException(source, nameof(source));
  160. Error.ThrowArgumentNullException(source, nameof(selector));
  161. return Min.MinAwaitAsync(source, selector, cancellationToken);
  162. }
  163. public static UniTask<Int64?> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
  164. {
  165. Error.ThrowArgumentNullException(source, nameof(source));
  166. Error.ThrowArgumentNullException(source, nameof(selector));
  167. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  168. }
  169. public static UniTask<Single?> MinAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default)
  170. {
  171. Error.ThrowArgumentNullException(source, nameof(source));
  172. return Min.MinAsync(source, cancellationToken);
  173. }
  174. public static UniTask<Single?> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default)
  175. {
  176. Error.ThrowArgumentNullException(source, nameof(source));
  177. Error.ThrowArgumentNullException(source, nameof(selector));
  178. return Min.MinAsync(source, selector, cancellationToken);
  179. }
  180. public static UniTask<Single?> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
  181. {
  182. Error.ThrowArgumentNullException(source, nameof(source));
  183. Error.ThrowArgumentNullException(source, nameof(selector));
  184. return Min.MinAwaitAsync(source, selector, cancellationToken);
  185. }
  186. public static UniTask<Single?> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
  187. {
  188. Error.ThrowArgumentNullException(source, nameof(source));
  189. Error.ThrowArgumentNullException(source, nameof(selector));
  190. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  191. }
  192. public static UniTask<Double?> MinAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default)
  193. {
  194. Error.ThrowArgumentNullException(source, nameof(source));
  195. return Min.MinAsync(source, cancellationToken);
  196. }
  197. public static UniTask<Double?> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default)
  198. {
  199. Error.ThrowArgumentNullException(source, nameof(source));
  200. Error.ThrowArgumentNullException(source, nameof(selector));
  201. return Min.MinAsync(source, selector, cancellationToken);
  202. }
  203. public static UniTask<Double?> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
  204. {
  205. Error.ThrowArgumentNullException(source, nameof(source));
  206. Error.ThrowArgumentNullException(source, nameof(selector));
  207. return Min.MinAwaitAsync(source, selector, cancellationToken);
  208. }
  209. public static UniTask<Double?> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
  210. {
  211. Error.ThrowArgumentNullException(source, nameof(source));
  212. Error.ThrowArgumentNullException(source, nameof(selector));
  213. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  214. }
  215. public static UniTask<Decimal?> MinAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default)
  216. {
  217. Error.ThrowArgumentNullException(source, nameof(source));
  218. return Min.MinAsync(source, cancellationToken);
  219. }
  220. public static UniTask<Decimal?> MinAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default)
  221. {
  222. Error.ThrowArgumentNullException(source, nameof(source));
  223. Error.ThrowArgumentNullException(source, nameof(selector));
  224. return Min.MinAsync(source, selector, cancellationToken);
  225. }
  226. public static UniTask<Decimal?> MinAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
  227. {
  228. Error.ThrowArgumentNullException(source, nameof(source));
  229. Error.ThrowArgumentNullException(source, nameof(selector));
  230. return Min.MinAwaitAsync(source, selector, cancellationToken);
  231. }
  232. public static UniTask<Decimal?> MinAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
  233. {
  234. Error.ThrowArgumentNullException(source, nameof(source));
  235. Error.ThrowArgumentNullException(source, nameof(selector));
  236. return Min.MinAwaitWithCancellationAsync(source, selector, cancellationToken);
  237. }
  238. }
  239. internal static partial class Min
  240. {
  241. public static async UniTask<Int32> MinAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken)
  242. {
  243. Int32 value = default;
  244. var e = source.GetAsyncEnumerator(cancellationToken);
  245. try
  246. {
  247. while (await e.MoveNextAsync())
  248. {
  249. value = e.Current;
  250. goto NEXT_LOOP;
  251. }
  252. throw Error.NoElements();
  253. NEXT_LOOP:
  254. while (await e.MoveNextAsync())
  255. {
  256. var x = e.Current;
  257. if (value > x)
  258. {
  259. value = x;
  260. }
  261. }
  262. }
  263. finally
  264. {
  265. if (e != null)
  266. {
  267. await e.DisposeAsync();
  268. }
  269. }
  270. return value;
  271. }
  272. public static async UniTask<Int32> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken)
  273. {
  274. Int32 value = default;
  275. var e = source.GetAsyncEnumerator(cancellationToken);
  276. try
  277. {
  278. while (await e.MoveNextAsync())
  279. {
  280. value = selector(e.Current);
  281. goto NEXT_LOOP;
  282. }
  283. throw Error.NoElements();
  284. NEXT_LOOP:
  285. while (await e.MoveNextAsync())
  286. {
  287. var x = selector(e.Current);
  288. if (value > x)
  289. {
  290. value = x;
  291. }
  292. }
  293. }
  294. finally
  295. {
  296. if (e != null)
  297. {
  298. await e.DisposeAsync();
  299. }
  300. }
  301. return value;
  302. }
  303. public static async UniTask<Int32> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken)
  304. {
  305. Int32 value = default;
  306. var e = source.GetAsyncEnumerator(cancellationToken);
  307. try
  308. {
  309. while (await e.MoveNextAsync())
  310. {
  311. value = await selector(e.Current);
  312. goto NEXT_LOOP;
  313. }
  314. throw Error.NoElements();
  315. NEXT_LOOP:
  316. while (await e.MoveNextAsync())
  317. {
  318. var x = await selector(e.Current);
  319. if (value > x)
  320. {
  321. value = x;
  322. }
  323. }
  324. }
  325. finally
  326. {
  327. if (e != null)
  328. {
  329. await e.DisposeAsync();
  330. }
  331. }
  332. return value;
  333. }
  334. public static async UniTask<Int32> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken)
  335. {
  336. Int32 value = default;
  337. var e = source.GetAsyncEnumerator(cancellationToken);
  338. try
  339. {
  340. while (await e.MoveNextAsync())
  341. {
  342. value = await selector(e.Current, cancellationToken);
  343. goto NEXT_LOOP;
  344. }
  345. throw Error.NoElements();
  346. NEXT_LOOP:
  347. while (await e.MoveNextAsync())
  348. {
  349. var x = await selector(e.Current, cancellationToken);
  350. if (value > x)
  351. {
  352. value = x;
  353. }
  354. }
  355. }
  356. finally
  357. {
  358. if (e != null)
  359. {
  360. await e.DisposeAsync();
  361. }
  362. }
  363. return value;
  364. }
  365. public static async UniTask<Int64> MinAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken)
  366. {
  367. Int64 value = default;
  368. var e = source.GetAsyncEnumerator(cancellationToken);
  369. try
  370. {
  371. while (await e.MoveNextAsync())
  372. {
  373. value = e.Current;
  374. goto NEXT_LOOP;
  375. }
  376. throw Error.NoElements();
  377. NEXT_LOOP:
  378. while (await e.MoveNextAsync())
  379. {
  380. var x = e.Current;
  381. if (value > x)
  382. {
  383. value = x;
  384. }
  385. }
  386. }
  387. finally
  388. {
  389. if (e != null)
  390. {
  391. await e.DisposeAsync();
  392. }
  393. }
  394. return value;
  395. }
  396. public static async UniTask<Int64> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken)
  397. {
  398. Int64 value = default;
  399. var e = source.GetAsyncEnumerator(cancellationToken);
  400. try
  401. {
  402. while (await e.MoveNextAsync())
  403. {
  404. value = selector(e.Current);
  405. goto NEXT_LOOP;
  406. }
  407. throw Error.NoElements();
  408. NEXT_LOOP:
  409. while (await e.MoveNextAsync())
  410. {
  411. var x = selector(e.Current);
  412. if (value > x)
  413. {
  414. value = x;
  415. }
  416. }
  417. }
  418. finally
  419. {
  420. if (e != null)
  421. {
  422. await e.DisposeAsync();
  423. }
  424. }
  425. return value;
  426. }
  427. public static async UniTask<Int64> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken)
  428. {
  429. Int64 value = default;
  430. var e = source.GetAsyncEnumerator(cancellationToken);
  431. try
  432. {
  433. while (await e.MoveNextAsync())
  434. {
  435. value = await selector(e.Current);
  436. goto NEXT_LOOP;
  437. }
  438. throw Error.NoElements();
  439. NEXT_LOOP:
  440. while (await e.MoveNextAsync())
  441. {
  442. var x = await selector(e.Current);
  443. if (value > x)
  444. {
  445. value = x;
  446. }
  447. }
  448. }
  449. finally
  450. {
  451. if (e != null)
  452. {
  453. await e.DisposeAsync();
  454. }
  455. }
  456. return value;
  457. }
  458. public static async UniTask<Int64> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken)
  459. {
  460. Int64 value = default;
  461. var e = source.GetAsyncEnumerator(cancellationToken);
  462. try
  463. {
  464. while (await e.MoveNextAsync())
  465. {
  466. value = await selector(e.Current, cancellationToken);
  467. goto NEXT_LOOP;
  468. }
  469. throw Error.NoElements();
  470. NEXT_LOOP:
  471. while (await e.MoveNextAsync())
  472. {
  473. var x = await selector(e.Current, cancellationToken);
  474. if (value > x)
  475. {
  476. value = x;
  477. }
  478. }
  479. }
  480. finally
  481. {
  482. if (e != null)
  483. {
  484. await e.DisposeAsync();
  485. }
  486. }
  487. return value;
  488. }
  489. public static async UniTask<Single> MinAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken)
  490. {
  491. Single value = default;
  492. var e = source.GetAsyncEnumerator(cancellationToken);
  493. try
  494. {
  495. while (await e.MoveNextAsync())
  496. {
  497. value = e.Current;
  498. goto NEXT_LOOP;
  499. }
  500. throw Error.NoElements();
  501. NEXT_LOOP:
  502. while (await e.MoveNextAsync())
  503. {
  504. var x = e.Current;
  505. if (value > x)
  506. {
  507. value = x;
  508. }
  509. }
  510. }
  511. finally
  512. {
  513. if (e != null)
  514. {
  515. await e.DisposeAsync();
  516. }
  517. }
  518. return value;
  519. }
  520. public static async UniTask<Single> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken)
  521. {
  522. Single value = default;
  523. var e = source.GetAsyncEnumerator(cancellationToken);
  524. try
  525. {
  526. while (await e.MoveNextAsync())
  527. {
  528. value = selector(e.Current);
  529. goto NEXT_LOOP;
  530. }
  531. throw Error.NoElements();
  532. NEXT_LOOP:
  533. while (await e.MoveNextAsync())
  534. {
  535. var x = selector(e.Current);
  536. if (value > x)
  537. {
  538. value = x;
  539. }
  540. }
  541. }
  542. finally
  543. {
  544. if (e != null)
  545. {
  546. await e.DisposeAsync();
  547. }
  548. }
  549. return value;
  550. }
  551. public static async UniTask<Single> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken)
  552. {
  553. Single value = default;
  554. var e = source.GetAsyncEnumerator(cancellationToken);
  555. try
  556. {
  557. while (await e.MoveNextAsync())
  558. {
  559. value = await selector(e.Current);
  560. goto NEXT_LOOP;
  561. }
  562. throw Error.NoElements();
  563. NEXT_LOOP:
  564. while (await e.MoveNextAsync())
  565. {
  566. var x = await selector(e.Current);
  567. if (value > x)
  568. {
  569. value = x;
  570. }
  571. }
  572. }
  573. finally
  574. {
  575. if (e != null)
  576. {
  577. await e.DisposeAsync();
  578. }
  579. }
  580. return value;
  581. }
  582. public static async UniTask<Single> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken)
  583. {
  584. Single value = default;
  585. var e = source.GetAsyncEnumerator(cancellationToken);
  586. try
  587. {
  588. while (await e.MoveNextAsync())
  589. {
  590. value = await selector(e.Current, cancellationToken);
  591. goto NEXT_LOOP;
  592. }
  593. throw Error.NoElements();
  594. NEXT_LOOP:
  595. while (await e.MoveNextAsync())
  596. {
  597. var x = await selector(e.Current, cancellationToken);
  598. if (value > x)
  599. {
  600. value = x;
  601. }
  602. }
  603. }
  604. finally
  605. {
  606. if (e != null)
  607. {
  608. await e.DisposeAsync();
  609. }
  610. }
  611. return value;
  612. }
  613. public static async UniTask<Double> MinAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken)
  614. {
  615. Double value = default;
  616. var e = source.GetAsyncEnumerator(cancellationToken);
  617. try
  618. {
  619. while (await e.MoveNextAsync())
  620. {
  621. value = e.Current;
  622. goto NEXT_LOOP;
  623. }
  624. throw Error.NoElements();
  625. NEXT_LOOP:
  626. while (await e.MoveNextAsync())
  627. {
  628. var x = e.Current;
  629. if (value > x)
  630. {
  631. value = x;
  632. }
  633. }
  634. }
  635. finally
  636. {
  637. if (e != null)
  638. {
  639. await e.DisposeAsync();
  640. }
  641. }
  642. return value;
  643. }
  644. public static async UniTask<Double> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken)
  645. {
  646. Double value = default;
  647. var e = source.GetAsyncEnumerator(cancellationToken);
  648. try
  649. {
  650. while (await e.MoveNextAsync())
  651. {
  652. value = selector(e.Current);
  653. goto NEXT_LOOP;
  654. }
  655. throw Error.NoElements();
  656. NEXT_LOOP:
  657. while (await e.MoveNextAsync())
  658. {
  659. var x = selector(e.Current);
  660. if (value > x)
  661. {
  662. value = x;
  663. }
  664. }
  665. }
  666. finally
  667. {
  668. if (e != null)
  669. {
  670. await e.DisposeAsync();
  671. }
  672. }
  673. return value;
  674. }
  675. public static async UniTask<Double> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken)
  676. {
  677. Double value = default;
  678. var e = source.GetAsyncEnumerator(cancellationToken);
  679. try
  680. {
  681. while (await e.MoveNextAsync())
  682. {
  683. value = await selector(e.Current);
  684. goto NEXT_LOOP;
  685. }
  686. throw Error.NoElements();
  687. NEXT_LOOP:
  688. while (await e.MoveNextAsync())
  689. {
  690. var x = await selector(e.Current);
  691. if (value > x)
  692. {
  693. value = x;
  694. }
  695. }
  696. }
  697. finally
  698. {
  699. if (e != null)
  700. {
  701. await e.DisposeAsync();
  702. }
  703. }
  704. return value;
  705. }
  706. public static async UniTask<Double> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken)
  707. {
  708. Double value = default;
  709. var e = source.GetAsyncEnumerator(cancellationToken);
  710. try
  711. {
  712. while (await e.MoveNextAsync())
  713. {
  714. value = await selector(e.Current, cancellationToken);
  715. goto NEXT_LOOP;
  716. }
  717. throw Error.NoElements();
  718. NEXT_LOOP:
  719. while (await e.MoveNextAsync())
  720. {
  721. var x = await selector(e.Current, cancellationToken);
  722. if (value > x)
  723. {
  724. value = x;
  725. }
  726. }
  727. }
  728. finally
  729. {
  730. if (e != null)
  731. {
  732. await e.DisposeAsync();
  733. }
  734. }
  735. return value;
  736. }
  737. public static async UniTask<Decimal> MinAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken)
  738. {
  739. Decimal value = default;
  740. var e = source.GetAsyncEnumerator(cancellationToken);
  741. try
  742. {
  743. while (await e.MoveNextAsync())
  744. {
  745. value = e.Current;
  746. goto NEXT_LOOP;
  747. }
  748. throw Error.NoElements();
  749. NEXT_LOOP:
  750. while (await e.MoveNextAsync())
  751. {
  752. var x = e.Current;
  753. if (value > x)
  754. {
  755. value = x;
  756. }
  757. }
  758. }
  759. finally
  760. {
  761. if (e != null)
  762. {
  763. await e.DisposeAsync();
  764. }
  765. }
  766. return value;
  767. }
  768. public static async UniTask<Decimal> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken)
  769. {
  770. Decimal value = default;
  771. var e = source.GetAsyncEnumerator(cancellationToken);
  772. try
  773. {
  774. while (await e.MoveNextAsync())
  775. {
  776. value = selector(e.Current);
  777. goto NEXT_LOOP;
  778. }
  779. throw Error.NoElements();
  780. NEXT_LOOP:
  781. while (await e.MoveNextAsync())
  782. {
  783. var x = selector(e.Current);
  784. if (value > x)
  785. {
  786. value = x;
  787. }
  788. }
  789. }
  790. finally
  791. {
  792. if (e != null)
  793. {
  794. await e.DisposeAsync();
  795. }
  796. }
  797. return value;
  798. }
  799. public static async UniTask<Decimal> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken)
  800. {
  801. Decimal value = default;
  802. var e = source.GetAsyncEnumerator(cancellationToken);
  803. try
  804. {
  805. while (await e.MoveNextAsync())
  806. {
  807. value = await selector(e.Current);
  808. goto NEXT_LOOP;
  809. }
  810. throw Error.NoElements();
  811. NEXT_LOOP:
  812. while (await e.MoveNextAsync())
  813. {
  814. var x = await selector(e.Current);
  815. if (value > x)
  816. {
  817. value = x;
  818. }
  819. }
  820. }
  821. finally
  822. {
  823. if (e != null)
  824. {
  825. await e.DisposeAsync();
  826. }
  827. }
  828. return value;
  829. }
  830. public static async UniTask<Decimal> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken)
  831. {
  832. Decimal value = default;
  833. var e = source.GetAsyncEnumerator(cancellationToken);
  834. try
  835. {
  836. while (await e.MoveNextAsync())
  837. {
  838. value = await selector(e.Current, cancellationToken);
  839. goto NEXT_LOOP;
  840. }
  841. throw Error.NoElements();
  842. NEXT_LOOP:
  843. while (await e.MoveNextAsync())
  844. {
  845. var x = await selector(e.Current, cancellationToken);
  846. if (value > x)
  847. {
  848. value = x;
  849. }
  850. }
  851. }
  852. finally
  853. {
  854. if (e != null)
  855. {
  856. await e.DisposeAsync();
  857. }
  858. }
  859. return value;
  860. }
  861. public static async UniTask<Int32?> MinAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken)
  862. {
  863. Int32? value = default;
  864. var e = source.GetAsyncEnumerator(cancellationToken);
  865. try
  866. {
  867. while (await e.MoveNextAsync())
  868. {
  869. value = e.Current;
  870. if(value == null) continue;
  871. goto NEXT_LOOP;
  872. }
  873. return default;
  874. NEXT_LOOP:
  875. while (await e.MoveNextAsync())
  876. {
  877. var x = e.Current;
  878. if( x == null) continue;
  879. if (value > x)
  880. {
  881. value = x;
  882. }
  883. }
  884. }
  885. finally
  886. {
  887. if (e != null)
  888. {
  889. await e.DisposeAsync();
  890. }
  891. }
  892. return value;
  893. }
  894. public static async UniTask<Int32?> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken)
  895. {
  896. Int32? value = default;
  897. var e = source.GetAsyncEnumerator(cancellationToken);
  898. try
  899. {
  900. while (await e.MoveNextAsync())
  901. {
  902. value = selector(e.Current);
  903. if(value == null) continue;
  904. goto NEXT_LOOP;
  905. }
  906. return default;
  907. NEXT_LOOP:
  908. while (await e.MoveNextAsync())
  909. {
  910. var x = selector(e.Current);
  911. if( x == null) continue;
  912. if (value > x)
  913. {
  914. value = x;
  915. }
  916. }
  917. }
  918. finally
  919. {
  920. if (e != null)
  921. {
  922. await e.DisposeAsync();
  923. }
  924. }
  925. return value;
  926. }
  927. public static async UniTask<Int32?> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken)
  928. {
  929. Int32? value = default;
  930. var e = source.GetAsyncEnumerator(cancellationToken);
  931. try
  932. {
  933. while (await e.MoveNextAsync())
  934. {
  935. value = await selector(e.Current);
  936. if(value == null) continue;
  937. goto NEXT_LOOP;
  938. }
  939. return default;
  940. NEXT_LOOP:
  941. while (await e.MoveNextAsync())
  942. {
  943. var x = await selector(e.Current);
  944. if( x == null) continue;
  945. if (value > x)
  946. {
  947. value = x;
  948. }
  949. }
  950. }
  951. finally
  952. {
  953. if (e != null)
  954. {
  955. await e.DisposeAsync();
  956. }
  957. }
  958. return value;
  959. }
  960. public static async UniTask<Int32?> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken)
  961. {
  962. Int32? value = default;
  963. var e = source.GetAsyncEnumerator(cancellationToken);
  964. try
  965. {
  966. while (await e.MoveNextAsync())
  967. {
  968. value = await selector(e.Current, cancellationToken);
  969. if(value == null) continue;
  970. goto NEXT_LOOP;
  971. }
  972. return default;
  973. NEXT_LOOP:
  974. while (await e.MoveNextAsync())
  975. {
  976. var x = await selector(e.Current, cancellationToken);
  977. if( x == null) continue;
  978. if (value > x)
  979. {
  980. value = x;
  981. }
  982. }
  983. }
  984. finally
  985. {
  986. if (e != null)
  987. {
  988. await e.DisposeAsync();
  989. }
  990. }
  991. return value;
  992. }
  993. public static async UniTask<Int64?> MinAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken)
  994. {
  995. Int64? value = default;
  996. var e = source.GetAsyncEnumerator(cancellationToken);
  997. try
  998. {
  999. while (await e.MoveNextAsync())
  1000. {
  1001. value = e.Current;
  1002. if(value == null) continue;
  1003. goto NEXT_LOOP;
  1004. }
  1005. return default;
  1006. NEXT_LOOP:
  1007. while (await e.MoveNextAsync())
  1008. {
  1009. var x = e.Current;
  1010. if( x == null) continue;
  1011. if (value > x)
  1012. {
  1013. value = x;
  1014. }
  1015. }
  1016. }
  1017. finally
  1018. {
  1019. if (e != null)
  1020. {
  1021. await e.DisposeAsync();
  1022. }
  1023. }
  1024. return value;
  1025. }
  1026. public static async UniTask<Int64?> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken)
  1027. {
  1028. Int64? value = default;
  1029. var e = source.GetAsyncEnumerator(cancellationToken);
  1030. try
  1031. {
  1032. while (await e.MoveNextAsync())
  1033. {
  1034. value = selector(e.Current);
  1035. if(value == null) continue;
  1036. goto NEXT_LOOP;
  1037. }
  1038. return default;
  1039. NEXT_LOOP:
  1040. while (await e.MoveNextAsync())
  1041. {
  1042. var x = selector(e.Current);
  1043. if( x == null) continue;
  1044. if (value > x)
  1045. {
  1046. value = x;
  1047. }
  1048. }
  1049. }
  1050. finally
  1051. {
  1052. if (e != null)
  1053. {
  1054. await e.DisposeAsync();
  1055. }
  1056. }
  1057. return value;
  1058. }
  1059. public static async UniTask<Int64?> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken)
  1060. {
  1061. Int64? value = default;
  1062. var e = source.GetAsyncEnumerator(cancellationToken);
  1063. try
  1064. {
  1065. while (await e.MoveNextAsync())
  1066. {
  1067. value = await selector(e.Current);
  1068. if(value == null) continue;
  1069. goto NEXT_LOOP;
  1070. }
  1071. return default;
  1072. NEXT_LOOP:
  1073. while (await e.MoveNextAsync())
  1074. {
  1075. var x = await selector(e.Current);
  1076. if( x == null) continue;
  1077. if (value > x)
  1078. {
  1079. value = x;
  1080. }
  1081. }
  1082. }
  1083. finally
  1084. {
  1085. if (e != null)
  1086. {
  1087. await e.DisposeAsync();
  1088. }
  1089. }
  1090. return value;
  1091. }
  1092. public static async UniTask<Int64?> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken)
  1093. {
  1094. Int64? value = default;
  1095. var e = source.GetAsyncEnumerator(cancellationToken);
  1096. try
  1097. {
  1098. while (await e.MoveNextAsync())
  1099. {
  1100. value = await selector(e.Current, cancellationToken);
  1101. if(value == null) continue;
  1102. goto NEXT_LOOP;
  1103. }
  1104. return default;
  1105. NEXT_LOOP:
  1106. while (await e.MoveNextAsync())
  1107. {
  1108. var x = await selector(e.Current, cancellationToken);
  1109. if( x == null) continue;
  1110. if (value > x)
  1111. {
  1112. value = x;
  1113. }
  1114. }
  1115. }
  1116. finally
  1117. {
  1118. if (e != null)
  1119. {
  1120. await e.DisposeAsync();
  1121. }
  1122. }
  1123. return value;
  1124. }
  1125. public static async UniTask<Single?> MinAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken)
  1126. {
  1127. Single? value = default;
  1128. var e = source.GetAsyncEnumerator(cancellationToken);
  1129. try
  1130. {
  1131. while (await e.MoveNextAsync())
  1132. {
  1133. value = e.Current;
  1134. if(value == null) continue;
  1135. goto NEXT_LOOP;
  1136. }
  1137. return default;
  1138. NEXT_LOOP:
  1139. while (await e.MoveNextAsync())
  1140. {
  1141. var x = e.Current;
  1142. if( x == null) continue;
  1143. if (value > x)
  1144. {
  1145. value = x;
  1146. }
  1147. }
  1148. }
  1149. finally
  1150. {
  1151. if (e != null)
  1152. {
  1153. await e.DisposeAsync();
  1154. }
  1155. }
  1156. return value;
  1157. }
  1158. public static async UniTask<Single?> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken)
  1159. {
  1160. Single? value = default;
  1161. var e = source.GetAsyncEnumerator(cancellationToken);
  1162. try
  1163. {
  1164. while (await e.MoveNextAsync())
  1165. {
  1166. value = selector(e.Current);
  1167. if(value == null) continue;
  1168. goto NEXT_LOOP;
  1169. }
  1170. return default;
  1171. NEXT_LOOP:
  1172. while (await e.MoveNextAsync())
  1173. {
  1174. var x = selector(e.Current);
  1175. if( x == null) continue;
  1176. if (value > x)
  1177. {
  1178. value = x;
  1179. }
  1180. }
  1181. }
  1182. finally
  1183. {
  1184. if (e != null)
  1185. {
  1186. await e.DisposeAsync();
  1187. }
  1188. }
  1189. return value;
  1190. }
  1191. public static async UniTask<Single?> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken)
  1192. {
  1193. Single? value = default;
  1194. var e = source.GetAsyncEnumerator(cancellationToken);
  1195. try
  1196. {
  1197. while (await e.MoveNextAsync())
  1198. {
  1199. value = await selector(e.Current);
  1200. if(value == null) continue;
  1201. goto NEXT_LOOP;
  1202. }
  1203. return default;
  1204. NEXT_LOOP:
  1205. while (await e.MoveNextAsync())
  1206. {
  1207. var x = await selector(e.Current);
  1208. if( x == null) continue;
  1209. if (value > x)
  1210. {
  1211. value = x;
  1212. }
  1213. }
  1214. }
  1215. finally
  1216. {
  1217. if (e != null)
  1218. {
  1219. await e.DisposeAsync();
  1220. }
  1221. }
  1222. return value;
  1223. }
  1224. public static async UniTask<Single?> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken)
  1225. {
  1226. Single? value = default;
  1227. var e = source.GetAsyncEnumerator(cancellationToken);
  1228. try
  1229. {
  1230. while (await e.MoveNextAsync())
  1231. {
  1232. value = await selector(e.Current, cancellationToken);
  1233. if(value == null) continue;
  1234. goto NEXT_LOOP;
  1235. }
  1236. return default;
  1237. NEXT_LOOP:
  1238. while (await e.MoveNextAsync())
  1239. {
  1240. var x = await selector(e.Current, cancellationToken);
  1241. if( x == null) continue;
  1242. if (value > x)
  1243. {
  1244. value = x;
  1245. }
  1246. }
  1247. }
  1248. finally
  1249. {
  1250. if (e != null)
  1251. {
  1252. await e.DisposeAsync();
  1253. }
  1254. }
  1255. return value;
  1256. }
  1257. public static async UniTask<Double?> MinAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken)
  1258. {
  1259. Double? value = default;
  1260. var e = source.GetAsyncEnumerator(cancellationToken);
  1261. try
  1262. {
  1263. while (await e.MoveNextAsync())
  1264. {
  1265. value = e.Current;
  1266. if(value == null) continue;
  1267. goto NEXT_LOOP;
  1268. }
  1269. return default;
  1270. NEXT_LOOP:
  1271. while (await e.MoveNextAsync())
  1272. {
  1273. var x = e.Current;
  1274. if( x == null) continue;
  1275. if (value > x)
  1276. {
  1277. value = x;
  1278. }
  1279. }
  1280. }
  1281. finally
  1282. {
  1283. if (e != null)
  1284. {
  1285. await e.DisposeAsync();
  1286. }
  1287. }
  1288. return value;
  1289. }
  1290. public static async UniTask<Double?> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken)
  1291. {
  1292. Double? value = default;
  1293. var e = source.GetAsyncEnumerator(cancellationToken);
  1294. try
  1295. {
  1296. while (await e.MoveNextAsync())
  1297. {
  1298. value = selector(e.Current);
  1299. if(value == null) continue;
  1300. goto NEXT_LOOP;
  1301. }
  1302. return default;
  1303. NEXT_LOOP:
  1304. while (await e.MoveNextAsync())
  1305. {
  1306. var x = selector(e.Current);
  1307. if( x == null) continue;
  1308. if (value > x)
  1309. {
  1310. value = x;
  1311. }
  1312. }
  1313. }
  1314. finally
  1315. {
  1316. if (e != null)
  1317. {
  1318. await e.DisposeAsync();
  1319. }
  1320. }
  1321. return value;
  1322. }
  1323. public static async UniTask<Double?> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken)
  1324. {
  1325. Double? value = default;
  1326. var e = source.GetAsyncEnumerator(cancellationToken);
  1327. try
  1328. {
  1329. while (await e.MoveNextAsync())
  1330. {
  1331. value = await selector(e.Current);
  1332. if(value == null) continue;
  1333. goto NEXT_LOOP;
  1334. }
  1335. return default;
  1336. NEXT_LOOP:
  1337. while (await e.MoveNextAsync())
  1338. {
  1339. var x = await selector(e.Current);
  1340. if( x == null) continue;
  1341. if (value > x)
  1342. {
  1343. value = x;
  1344. }
  1345. }
  1346. }
  1347. finally
  1348. {
  1349. if (e != null)
  1350. {
  1351. await e.DisposeAsync();
  1352. }
  1353. }
  1354. return value;
  1355. }
  1356. public static async UniTask<Double?> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken)
  1357. {
  1358. Double? value = default;
  1359. var e = source.GetAsyncEnumerator(cancellationToken);
  1360. try
  1361. {
  1362. while (await e.MoveNextAsync())
  1363. {
  1364. value = await selector(e.Current, cancellationToken);
  1365. if(value == null) continue;
  1366. goto NEXT_LOOP;
  1367. }
  1368. return default;
  1369. NEXT_LOOP:
  1370. while (await e.MoveNextAsync())
  1371. {
  1372. var x = await selector(e.Current, cancellationToken);
  1373. if( x == null) continue;
  1374. if (value > x)
  1375. {
  1376. value = x;
  1377. }
  1378. }
  1379. }
  1380. finally
  1381. {
  1382. if (e != null)
  1383. {
  1384. await e.DisposeAsync();
  1385. }
  1386. }
  1387. return value;
  1388. }
  1389. public static async UniTask<Decimal?> MinAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken)
  1390. {
  1391. Decimal? value = default;
  1392. var e = source.GetAsyncEnumerator(cancellationToken);
  1393. try
  1394. {
  1395. while (await e.MoveNextAsync())
  1396. {
  1397. value = e.Current;
  1398. if(value == null) continue;
  1399. goto NEXT_LOOP;
  1400. }
  1401. return default;
  1402. NEXT_LOOP:
  1403. while (await e.MoveNextAsync())
  1404. {
  1405. var x = e.Current;
  1406. if( x == null) continue;
  1407. if (value > x)
  1408. {
  1409. value = x;
  1410. }
  1411. }
  1412. }
  1413. finally
  1414. {
  1415. if (e != null)
  1416. {
  1417. await e.DisposeAsync();
  1418. }
  1419. }
  1420. return value;
  1421. }
  1422. public static async UniTask<Decimal?> MinAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken)
  1423. {
  1424. Decimal? value = default;
  1425. var e = source.GetAsyncEnumerator(cancellationToken);
  1426. try
  1427. {
  1428. while (await e.MoveNextAsync())
  1429. {
  1430. value = selector(e.Current);
  1431. if(value == null) continue;
  1432. goto NEXT_LOOP;
  1433. }
  1434. return default;
  1435. NEXT_LOOP:
  1436. while (await e.MoveNextAsync())
  1437. {
  1438. var x = selector(e.Current);
  1439. if( x == null) continue;
  1440. if (value > x)
  1441. {
  1442. value = x;
  1443. }
  1444. }
  1445. }
  1446. finally
  1447. {
  1448. if (e != null)
  1449. {
  1450. await e.DisposeAsync();
  1451. }
  1452. }
  1453. return value;
  1454. }
  1455. public static async UniTask<Decimal?> MinAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
  1456. {
  1457. Decimal? value = default;
  1458. var e = source.GetAsyncEnumerator(cancellationToken);
  1459. try
  1460. {
  1461. while (await e.MoveNextAsync())
  1462. {
  1463. value = await selector(e.Current);
  1464. if(value == null) continue;
  1465. goto NEXT_LOOP;
  1466. }
  1467. return default;
  1468. NEXT_LOOP:
  1469. while (await e.MoveNextAsync())
  1470. {
  1471. var x = await selector(e.Current);
  1472. if( x == null) continue;
  1473. if (value > x)
  1474. {
  1475. value = x;
  1476. }
  1477. }
  1478. }
  1479. finally
  1480. {
  1481. if (e != null)
  1482. {
  1483. await e.DisposeAsync();
  1484. }
  1485. }
  1486. return value;
  1487. }
  1488. public static async UniTask<Decimal?> MinAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
  1489. {
  1490. Decimal? value = default;
  1491. var e = source.GetAsyncEnumerator(cancellationToken);
  1492. try
  1493. {
  1494. while (await e.MoveNextAsync())
  1495. {
  1496. value = await selector(e.Current, cancellationToken);
  1497. if(value == null) continue;
  1498. goto NEXT_LOOP;
  1499. }
  1500. return default;
  1501. NEXT_LOOP:
  1502. while (await e.MoveNextAsync())
  1503. {
  1504. var x = await selector(e.Current, cancellationToken);
  1505. if( x == null) continue;
  1506. if (value > x)
  1507. {
  1508. value = x;
  1509. }
  1510. }
  1511. }
  1512. finally
  1513. {
  1514. if (e != null)
  1515. {
  1516. await e.DisposeAsync();
  1517. }
  1518. }
  1519. return value;
  1520. }
  1521. }
  1522. public static partial class UniTaskAsyncEnumerable
  1523. {
  1524. public static UniTask<Int32> MaxAsync(this IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken = default)
  1525. {
  1526. Error.ThrowArgumentNullException(source, nameof(source));
  1527. return Max.MaxAsync(source, cancellationToken);
  1528. }
  1529. public static UniTask<Int32> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken = default)
  1530. {
  1531. Error.ThrowArgumentNullException(source, nameof(source));
  1532. Error.ThrowArgumentNullException(source, nameof(selector));
  1533. return Max.MaxAsync(source, selector, cancellationToken);
  1534. }
  1535. public static UniTask<Int32> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
  1536. {
  1537. Error.ThrowArgumentNullException(source, nameof(source));
  1538. Error.ThrowArgumentNullException(source, nameof(selector));
  1539. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1540. }
  1541. public static UniTask<Int32> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken = default)
  1542. {
  1543. Error.ThrowArgumentNullException(source, nameof(source));
  1544. Error.ThrowArgumentNullException(source, nameof(selector));
  1545. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1546. }
  1547. public static UniTask<Int64> MaxAsync(this IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken = default)
  1548. {
  1549. Error.ThrowArgumentNullException(source, nameof(source));
  1550. return Max.MaxAsync(source, cancellationToken);
  1551. }
  1552. public static UniTask<Int64> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken = default)
  1553. {
  1554. Error.ThrowArgumentNullException(source, nameof(source));
  1555. Error.ThrowArgumentNullException(source, nameof(selector));
  1556. return Max.MaxAsync(source, selector, cancellationToken);
  1557. }
  1558. public static UniTask<Int64> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
  1559. {
  1560. Error.ThrowArgumentNullException(source, nameof(source));
  1561. Error.ThrowArgumentNullException(source, nameof(selector));
  1562. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1563. }
  1564. public static UniTask<Int64> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken = default)
  1565. {
  1566. Error.ThrowArgumentNullException(source, nameof(source));
  1567. Error.ThrowArgumentNullException(source, nameof(selector));
  1568. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1569. }
  1570. public static UniTask<Single> MaxAsync(this IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken = default)
  1571. {
  1572. Error.ThrowArgumentNullException(source, nameof(source));
  1573. return Max.MaxAsync(source, cancellationToken);
  1574. }
  1575. public static UniTask<Single> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken = default)
  1576. {
  1577. Error.ThrowArgumentNullException(source, nameof(source));
  1578. Error.ThrowArgumentNullException(source, nameof(selector));
  1579. return Max.MaxAsync(source, selector, cancellationToken);
  1580. }
  1581. public static UniTask<Single> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken = default)
  1582. {
  1583. Error.ThrowArgumentNullException(source, nameof(source));
  1584. Error.ThrowArgumentNullException(source, nameof(selector));
  1585. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1586. }
  1587. public static UniTask<Single> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken = default)
  1588. {
  1589. Error.ThrowArgumentNullException(source, nameof(source));
  1590. Error.ThrowArgumentNullException(source, nameof(selector));
  1591. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1592. }
  1593. public static UniTask<Double> MaxAsync(this IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken = default)
  1594. {
  1595. Error.ThrowArgumentNullException(source, nameof(source));
  1596. return Max.MaxAsync(source, cancellationToken);
  1597. }
  1598. public static UniTask<Double> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken = default)
  1599. {
  1600. Error.ThrowArgumentNullException(source, nameof(source));
  1601. Error.ThrowArgumentNullException(source, nameof(selector));
  1602. return Max.MaxAsync(source, selector, cancellationToken);
  1603. }
  1604. public static UniTask<Double> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken = default)
  1605. {
  1606. Error.ThrowArgumentNullException(source, nameof(source));
  1607. Error.ThrowArgumentNullException(source, nameof(selector));
  1608. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1609. }
  1610. public static UniTask<Double> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken = default)
  1611. {
  1612. Error.ThrowArgumentNullException(source, nameof(source));
  1613. Error.ThrowArgumentNullException(source, nameof(selector));
  1614. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1615. }
  1616. public static UniTask<Decimal> MaxAsync(this IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken = default)
  1617. {
  1618. Error.ThrowArgumentNullException(source, nameof(source));
  1619. return Max.MaxAsync(source, cancellationToken);
  1620. }
  1621. public static UniTask<Decimal> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken = default)
  1622. {
  1623. Error.ThrowArgumentNullException(source, nameof(source));
  1624. Error.ThrowArgumentNullException(source, nameof(selector));
  1625. return Max.MaxAsync(source, selector, cancellationToken);
  1626. }
  1627. public static UniTask<Decimal> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
  1628. {
  1629. Error.ThrowArgumentNullException(source, nameof(source));
  1630. Error.ThrowArgumentNullException(source, nameof(selector));
  1631. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1632. }
  1633. public static UniTask<Decimal> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken = default)
  1634. {
  1635. Error.ThrowArgumentNullException(source, nameof(source));
  1636. Error.ThrowArgumentNullException(source, nameof(selector));
  1637. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1638. }
  1639. public static UniTask<Int32?> MaxAsync(this IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken = default)
  1640. {
  1641. Error.ThrowArgumentNullException(source, nameof(source));
  1642. return Max.MaxAsync(source, cancellationToken);
  1643. }
  1644. public static UniTask<Int32?> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken = default)
  1645. {
  1646. Error.ThrowArgumentNullException(source, nameof(source));
  1647. Error.ThrowArgumentNullException(source, nameof(selector));
  1648. return Max.MaxAsync(source, selector, cancellationToken);
  1649. }
  1650. public static UniTask<Int32?> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
  1651. {
  1652. Error.ThrowArgumentNullException(source, nameof(source));
  1653. Error.ThrowArgumentNullException(source, nameof(selector));
  1654. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1655. }
  1656. public static UniTask<Int32?> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken = default)
  1657. {
  1658. Error.ThrowArgumentNullException(source, nameof(source));
  1659. Error.ThrowArgumentNullException(source, nameof(selector));
  1660. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1661. }
  1662. public static UniTask<Int64?> MaxAsync(this IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken = default)
  1663. {
  1664. Error.ThrowArgumentNullException(source, nameof(source));
  1665. return Max.MaxAsync(source, cancellationToken);
  1666. }
  1667. public static UniTask<Int64?> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken = default)
  1668. {
  1669. Error.ThrowArgumentNullException(source, nameof(source));
  1670. Error.ThrowArgumentNullException(source, nameof(selector));
  1671. return Max.MaxAsync(source, selector, cancellationToken);
  1672. }
  1673. public static UniTask<Int64?> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
  1674. {
  1675. Error.ThrowArgumentNullException(source, nameof(source));
  1676. Error.ThrowArgumentNullException(source, nameof(selector));
  1677. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1678. }
  1679. public static UniTask<Int64?> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken = default)
  1680. {
  1681. Error.ThrowArgumentNullException(source, nameof(source));
  1682. Error.ThrowArgumentNullException(source, nameof(selector));
  1683. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1684. }
  1685. public static UniTask<Single?> MaxAsync(this IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken = default)
  1686. {
  1687. Error.ThrowArgumentNullException(source, nameof(source));
  1688. return Max.MaxAsync(source, cancellationToken);
  1689. }
  1690. public static UniTask<Single?> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken = default)
  1691. {
  1692. Error.ThrowArgumentNullException(source, nameof(source));
  1693. Error.ThrowArgumentNullException(source, nameof(selector));
  1694. return Max.MaxAsync(source, selector, cancellationToken);
  1695. }
  1696. public static UniTask<Single?> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
  1697. {
  1698. Error.ThrowArgumentNullException(source, nameof(source));
  1699. Error.ThrowArgumentNullException(source, nameof(selector));
  1700. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1701. }
  1702. public static UniTask<Single?> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken = default)
  1703. {
  1704. Error.ThrowArgumentNullException(source, nameof(source));
  1705. Error.ThrowArgumentNullException(source, nameof(selector));
  1706. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1707. }
  1708. public static UniTask<Double?> MaxAsync(this IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken = default)
  1709. {
  1710. Error.ThrowArgumentNullException(source, nameof(source));
  1711. return Max.MaxAsync(source, cancellationToken);
  1712. }
  1713. public static UniTask<Double?> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken = default)
  1714. {
  1715. Error.ThrowArgumentNullException(source, nameof(source));
  1716. Error.ThrowArgumentNullException(source, nameof(selector));
  1717. return Max.MaxAsync(source, selector, cancellationToken);
  1718. }
  1719. public static UniTask<Double?> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
  1720. {
  1721. Error.ThrowArgumentNullException(source, nameof(source));
  1722. Error.ThrowArgumentNullException(source, nameof(selector));
  1723. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1724. }
  1725. public static UniTask<Double?> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken = default)
  1726. {
  1727. Error.ThrowArgumentNullException(source, nameof(source));
  1728. Error.ThrowArgumentNullException(source, nameof(selector));
  1729. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1730. }
  1731. public static UniTask<Decimal?> MaxAsync(this IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken = default)
  1732. {
  1733. Error.ThrowArgumentNullException(source, nameof(source));
  1734. return Max.MaxAsync(source, cancellationToken);
  1735. }
  1736. public static UniTask<Decimal?> MaxAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken = default)
  1737. {
  1738. Error.ThrowArgumentNullException(source, nameof(source));
  1739. Error.ThrowArgumentNullException(source, nameof(selector));
  1740. return Max.MaxAsync(source, selector, cancellationToken);
  1741. }
  1742. public static UniTask<Decimal?> MaxAwaitAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
  1743. {
  1744. Error.ThrowArgumentNullException(source, nameof(source));
  1745. Error.ThrowArgumentNullException(source, nameof(selector));
  1746. return Max.MaxAwaitAsync(source, selector, cancellationToken);
  1747. }
  1748. public static UniTask<Decimal?> MaxAwaitWithCancellationAsync<TSource>(this IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken = default)
  1749. {
  1750. Error.ThrowArgumentNullException(source, nameof(source));
  1751. Error.ThrowArgumentNullException(source, nameof(selector));
  1752. return Max.MaxAwaitWithCancellationAsync(source, selector, cancellationToken);
  1753. }
  1754. }
  1755. internal static partial class Max
  1756. {
  1757. public static async UniTask<Int32> MaxAsync(IUniTaskAsyncEnumerable<Int32> source, CancellationToken cancellationToken)
  1758. {
  1759. Int32 value = default;
  1760. var e = source.GetAsyncEnumerator(cancellationToken);
  1761. try
  1762. {
  1763. while (await e.MoveNextAsync())
  1764. {
  1765. value = e.Current;
  1766. goto NEXT_LOOP;
  1767. }
  1768. throw Error.NoElements();
  1769. NEXT_LOOP:
  1770. while (await e.MoveNextAsync())
  1771. {
  1772. var x = e.Current;
  1773. if (value < x)
  1774. {
  1775. value = x;
  1776. }
  1777. }
  1778. }
  1779. finally
  1780. {
  1781. if (e != null)
  1782. {
  1783. await e.DisposeAsync();
  1784. }
  1785. }
  1786. return value;
  1787. }
  1788. public static async UniTask<Int32> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32> selector, CancellationToken cancellationToken)
  1789. {
  1790. Int32 value = default;
  1791. var e = source.GetAsyncEnumerator(cancellationToken);
  1792. try
  1793. {
  1794. while (await e.MoveNextAsync())
  1795. {
  1796. value = selector(e.Current);
  1797. goto NEXT_LOOP;
  1798. }
  1799. throw Error.NoElements();
  1800. NEXT_LOOP:
  1801. while (await e.MoveNextAsync())
  1802. {
  1803. var x = selector(e.Current);
  1804. if (value < x)
  1805. {
  1806. value = x;
  1807. }
  1808. }
  1809. }
  1810. finally
  1811. {
  1812. if (e != null)
  1813. {
  1814. await e.DisposeAsync();
  1815. }
  1816. }
  1817. return value;
  1818. }
  1819. public static async UniTask<Int32> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32>> selector, CancellationToken cancellationToken)
  1820. {
  1821. Int32 value = default;
  1822. var e = source.GetAsyncEnumerator(cancellationToken);
  1823. try
  1824. {
  1825. while (await e.MoveNextAsync())
  1826. {
  1827. value = await selector(e.Current);
  1828. goto NEXT_LOOP;
  1829. }
  1830. throw Error.NoElements();
  1831. NEXT_LOOP:
  1832. while (await e.MoveNextAsync())
  1833. {
  1834. var x = await selector(e.Current);
  1835. if (value < x)
  1836. {
  1837. value = x;
  1838. }
  1839. }
  1840. }
  1841. finally
  1842. {
  1843. if (e != null)
  1844. {
  1845. await e.DisposeAsync();
  1846. }
  1847. }
  1848. return value;
  1849. }
  1850. public static async UniTask<Int32> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32>> selector, CancellationToken cancellationToken)
  1851. {
  1852. Int32 value = default;
  1853. var e = source.GetAsyncEnumerator(cancellationToken);
  1854. try
  1855. {
  1856. while (await e.MoveNextAsync())
  1857. {
  1858. value = await selector(e.Current, cancellationToken);
  1859. goto NEXT_LOOP;
  1860. }
  1861. throw Error.NoElements();
  1862. NEXT_LOOP:
  1863. while (await e.MoveNextAsync())
  1864. {
  1865. var x = await selector(e.Current, cancellationToken);
  1866. if (value < x)
  1867. {
  1868. value = x;
  1869. }
  1870. }
  1871. }
  1872. finally
  1873. {
  1874. if (e != null)
  1875. {
  1876. await e.DisposeAsync();
  1877. }
  1878. }
  1879. return value;
  1880. }
  1881. public static async UniTask<Int64> MaxAsync(IUniTaskAsyncEnumerable<Int64> source, CancellationToken cancellationToken)
  1882. {
  1883. Int64 value = default;
  1884. var e = source.GetAsyncEnumerator(cancellationToken);
  1885. try
  1886. {
  1887. while (await e.MoveNextAsync())
  1888. {
  1889. value = e.Current;
  1890. goto NEXT_LOOP;
  1891. }
  1892. throw Error.NoElements();
  1893. NEXT_LOOP:
  1894. while (await e.MoveNextAsync())
  1895. {
  1896. var x = e.Current;
  1897. if (value < x)
  1898. {
  1899. value = x;
  1900. }
  1901. }
  1902. }
  1903. finally
  1904. {
  1905. if (e != null)
  1906. {
  1907. await e.DisposeAsync();
  1908. }
  1909. }
  1910. return value;
  1911. }
  1912. public static async UniTask<Int64> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64> selector, CancellationToken cancellationToken)
  1913. {
  1914. Int64 value = default;
  1915. var e = source.GetAsyncEnumerator(cancellationToken);
  1916. try
  1917. {
  1918. while (await e.MoveNextAsync())
  1919. {
  1920. value = selector(e.Current);
  1921. goto NEXT_LOOP;
  1922. }
  1923. throw Error.NoElements();
  1924. NEXT_LOOP:
  1925. while (await e.MoveNextAsync())
  1926. {
  1927. var x = selector(e.Current);
  1928. if (value < x)
  1929. {
  1930. value = x;
  1931. }
  1932. }
  1933. }
  1934. finally
  1935. {
  1936. if (e != null)
  1937. {
  1938. await e.DisposeAsync();
  1939. }
  1940. }
  1941. return value;
  1942. }
  1943. public static async UniTask<Int64> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64>> selector, CancellationToken cancellationToken)
  1944. {
  1945. Int64 value = default;
  1946. var e = source.GetAsyncEnumerator(cancellationToken);
  1947. try
  1948. {
  1949. while (await e.MoveNextAsync())
  1950. {
  1951. value = await selector(e.Current);
  1952. goto NEXT_LOOP;
  1953. }
  1954. throw Error.NoElements();
  1955. NEXT_LOOP:
  1956. while (await e.MoveNextAsync())
  1957. {
  1958. var x = await selector(e.Current);
  1959. if (value < x)
  1960. {
  1961. value = x;
  1962. }
  1963. }
  1964. }
  1965. finally
  1966. {
  1967. if (e != null)
  1968. {
  1969. await e.DisposeAsync();
  1970. }
  1971. }
  1972. return value;
  1973. }
  1974. public static async UniTask<Int64> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64>> selector, CancellationToken cancellationToken)
  1975. {
  1976. Int64 value = default;
  1977. var e = source.GetAsyncEnumerator(cancellationToken);
  1978. try
  1979. {
  1980. while (await e.MoveNextAsync())
  1981. {
  1982. value = await selector(e.Current, cancellationToken);
  1983. goto NEXT_LOOP;
  1984. }
  1985. throw Error.NoElements();
  1986. NEXT_LOOP:
  1987. while (await e.MoveNextAsync())
  1988. {
  1989. var x = await selector(e.Current, cancellationToken);
  1990. if (value < x)
  1991. {
  1992. value = x;
  1993. }
  1994. }
  1995. }
  1996. finally
  1997. {
  1998. if (e != null)
  1999. {
  2000. await e.DisposeAsync();
  2001. }
  2002. }
  2003. return value;
  2004. }
  2005. public static async UniTask<Single> MaxAsync(IUniTaskAsyncEnumerable<Single> source, CancellationToken cancellationToken)
  2006. {
  2007. Single value = default;
  2008. var e = source.GetAsyncEnumerator(cancellationToken);
  2009. try
  2010. {
  2011. while (await e.MoveNextAsync())
  2012. {
  2013. value = e.Current;
  2014. goto NEXT_LOOP;
  2015. }
  2016. throw Error.NoElements();
  2017. NEXT_LOOP:
  2018. while (await e.MoveNextAsync())
  2019. {
  2020. var x = e.Current;
  2021. if (value < x)
  2022. {
  2023. value = x;
  2024. }
  2025. }
  2026. }
  2027. finally
  2028. {
  2029. if (e != null)
  2030. {
  2031. await e.DisposeAsync();
  2032. }
  2033. }
  2034. return value;
  2035. }
  2036. public static async UniTask<Single> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single> selector, CancellationToken cancellationToken)
  2037. {
  2038. Single value = default;
  2039. var e = source.GetAsyncEnumerator(cancellationToken);
  2040. try
  2041. {
  2042. while (await e.MoveNextAsync())
  2043. {
  2044. value = selector(e.Current);
  2045. goto NEXT_LOOP;
  2046. }
  2047. throw Error.NoElements();
  2048. NEXT_LOOP:
  2049. while (await e.MoveNextAsync())
  2050. {
  2051. var x = selector(e.Current);
  2052. if (value < x)
  2053. {
  2054. value = x;
  2055. }
  2056. }
  2057. }
  2058. finally
  2059. {
  2060. if (e != null)
  2061. {
  2062. await e.DisposeAsync();
  2063. }
  2064. }
  2065. return value;
  2066. }
  2067. public static async UniTask<Single> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single>> selector, CancellationToken cancellationToken)
  2068. {
  2069. Single value = default;
  2070. var e = source.GetAsyncEnumerator(cancellationToken);
  2071. try
  2072. {
  2073. while (await e.MoveNextAsync())
  2074. {
  2075. value = await selector(e.Current);
  2076. goto NEXT_LOOP;
  2077. }
  2078. throw Error.NoElements();
  2079. NEXT_LOOP:
  2080. while (await e.MoveNextAsync())
  2081. {
  2082. var x = await selector(e.Current);
  2083. if (value < x)
  2084. {
  2085. value = x;
  2086. }
  2087. }
  2088. }
  2089. finally
  2090. {
  2091. if (e != null)
  2092. {
  2093. await e.DisposeAsync();
  2094. }
  2095. }
  2096. return value;
  2097. }
  2098. public static async UniTask<Single> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single>> selector, CancellationToken cancellationToken)
  2099. {
  2100. Single value = default;
  2101. var e = source.GetAsyncEnumerator(cancellationToken);
  2102. try
  2103. {
  2104. while (await e.MoveNextAsync())
  2105. {
  2106. value = await selector(e.Current, cancellationToken);
  2107. goto NEXT_LOOP;
  2108. }
  2109. throw Error.NoElements();
  2110. NEXT_LOOP:
  2111. while (await e.MoveNextAsync())
  2112. {
  2113. var x = await selector(e.Current, cancellationToken);
  2114. if (value < x)
  2115. {
  2116. value = x;
  2117. }
  2118. }
  2119. }
  2120. finally
  2121. {
  2122. if (e != null)
  2123. {
  2124. await e.DisposeAsync();
  2125. }
  2126. }
  2127. return value;
  2128. }
  2129. public static async UniTask<Double> MaxAsync(IUniTaskAsyncEnumerable<Double> source, CancellationToken cancellationToken)
  2130. {
  2131. Double value = default;
  2132. var e = source.GetAsyncEnumerator(cancellationToken);
  2133. try
  2134. {
  2135. while (await e.MoveNextAsync())
  2136. {
  2137. value = e.Current;
  2138. goto NEXT_LOOP;
  2139. }
  2140. throw Error.NoElements();
  2141. NEXT_LOOP:
  2142. while (await e.MoveNextAsync())
  2143. {
  2144. var x = e.Current;
  2145. if (value < x)
  2146. {
  2147. value = x;
  2148. }
  2149. }
  2150. }
  2151. finally
  2152. {
  2153. if (e != null)
  2154. {
  2155. await e.DisposeAsync();
  2156. }
  2157. }
  2158. return value;
  2159. }
  2160. public static async UniTask<Double> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double> selector, CancellationToken cancellationToken)
  2161. {
  2162. Double value = default;
  2163. var e = source.GetAsyncEnumerator(cancellationToken);
  2164. try
  2165. {
  2166. while (await e.MoveNextAsync())
  2167. {
  2168. value = selector(e.Current);
  2169. goto NEXT_LOOP;
  2170. }
  2171. throw Error.NoElements();
  2172. NEXT_LOOP:
  2173. while (await e.MoveNextAsync())
  2174. {
  2175. var x = selector(e.Current);
  2176. if (value < x)
  2177. {
  2178. value = x;
  2179. }
  2180. }
  2181. }
  2182. finally
  2183. {
  2184. if (e != null)
  2185. {
  2186. await e.DisposeAsync();
  2187. }
  2188. }
  2189. return value;
  2190. }
  2191. public static async UniTask<Double> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double>> selector, CancellationToken cancellationToken)
  2192. {
  2193. Double value = default;
  2194. var e = source.GetAsyncEnumerator(cancellationToken);
  2195. try
  2196. {
  2197. while (await e.MoveNextAsync())
  2198. {
  2199. value = await selector(e.Current);
  2200. goto NEXT_LOOP;
  2201. }
  2202. throw Error.NoElements();
  2203. NEXT_LOOP:
  2204. while (await e.MoveNextAsync())
  2205. {
  2206. var x = await selector(e.Current);
  2207. if (value < x)
  2208. {
  2209. value = x;
  2210. }
  2211. }
  2212. }
  2213. finally
  2214. {
  2215. if (e != null)
  2216. {
  2217. await e.DisposeAsync();
  2218. }
  2219. }
  2220. return value;
  2221. }
  2222. public static async UniTask<Double> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double>> selector, CancellationToken cancellationToken)
  2223. {
  2224. Double value = default;
  2225. var e = source.GetAsyncEnumerator(cancellationToken);
  2226. try
  2227. {
  2228. while (await e.MoveNextAsync())
  2229. {
  2230. value = await selector(e.Current, cancellationToken);
  2231. goto NEXT_LOOP;
  2232. }
  2233. throw Error.NoElements();
  2234. NEXT_LOOP:
  2235. while (await e.MoveNextAsync())
  2236. {
  2237. var x = await selector(e.Current, cancellationToken);
  2238. if (value < x)
  2239. {
  2240. value = x;
  2241. }
  2242. }
  2243. }
  2244. finally
  2245. {
  2246. if (e != null)
  2247. {
  2248. await e.DisposeAsync();
  2249. }
  2250. }
  2251. return value;
  2252. }
  2253. public static async UniTask<Decimal> MaxAsync(IUniTaskAsyncEnumerable<Decimal> source, CancellationToken cancellationToken)
  2254. {
  2255. Decimal value = default;
  2256. var e = source.GetAsyncEnumerator(cancellationToken);
  2257. try
  2258. {
  2259. while (await e.MoveNextAsync())
  2260. {
  2261. value = e.Current;
  2262. goto NEXT_LOOP;
  2263. }
  2264. throw Error.NoElements();
  2265. NEXT_LOOP:
  2266. while (await e.MoveNextAsync())
  2267. {
  2268. var x = e.Current;
  2269. if (value < x)
  2270. {
  2271. value = x;
  2272. }
  2273. }
  2274. }
  2275. finally
  2276. {
  2277. if (e != null)
  2278. {
  2279. await e.DisposeAsync();
  2280. }
  2281. }
  2282. return value;
  2283. }
  2284. public static async UniTask<Decimal> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal> selector, CancellationToken cancellationToken)
  2285. {
  2286. Decimal value = default;
  2287. var e = source.GetAsyncEnumerator(cancellationToken);
  2288. try
  2289. {
  2290. while (await e.MoveNextAsync())
  2291. {
  2292. value = selector(e.Current);
  2293. goto NEXT_LOOP;
  2294. }
  2295. throw Error.NoElements();
  2296. NEXT_LOOP:
  2297. while (await e.MoveNextAsync())
  2298. {
  2299. var x = selector(e.Current);
  2300. if (value < x)
  2301. {
  2302. value = x;
  2303. }
  2304. }
  2305. }
  2306. finally
  2307. {
  2308. if (e != null)
  2309. {
  2310. await e.DisposeAsync();
  2311. }
  2312. }
  2313. return value;
  2314. }
  2315. public static async UniTask<Decimal> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal>> selector, CancellationToken cancellationToken)
  2316. {
  2317. Decimal value = default;
  2318. var e = source.GetAsyncEnumerator(cancellationToken);
  2319. try
  2320. {
  2321. while (await e.MoveNextAsync())
  2322. {
  2323. value = await selector(e.Current);
  2324. goto NEXT_LOOP;
  2325. }
  2326. throw Error.NoElements();
  2327. NEXT_LOOP:
  2328. while (await e.MoveNextAsync())
  2329. {
  2330. var x = await selector(e.Current);
  2331. if (value < x)
  2332. {
  2333. value = x;
  2334. }
  2335. }
  2336. }
  2337. finally
  2338. {
  2339. if (e != null)
  2340. {
  2341. await e.DisposeAsync();
  2342. }
  2343. }
  2344. return value;
  2345. }
  2346. public static async UniTask<Decimal> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal>> selector, CancellationToken cancellationToken)
  2347. {
  2348. Decimal value = default;
  2349. var e = source.GetAsyncEnumerator(cancellationToken);
  2350. try
  2351. {
  2352. while (await e.MoveNextAsync())
  2353. {
  2354. value = await selector(e.Current, cancellationToken);
  2355. goto NEXT_LOOP;
  2356. }
  2357. throw Error.NoElements();
  2358. NEXT_LOOP:
  2359. while (await e.MoveNextAsync())
  2360. {
  2361. var x = await selector(e.Current, cancellationToken);
  2362. if (value < x)
  2363. {
  2364. value = x;
  2365. }
  2366. }
  2367. }
  2368. finally
  2369. {
  2370. if (e != null)
  2371. {
  2372. await e.DisposeAsync();
  2373. }
  2374. }
  2375. return value;
  2376. }
  2377. public static async UniTask<Int32?> MaxAsync(IUniTaskAsyncEnumerable<Int32?> source, CancellationToken cancellationToken)
  2378. {
  2379. Int32? value = default;
  2380. var e = source.GetAsyncEnumerator(cancellationToken);
  2381. try
  2382. {
  2383. while (await e.MoveNextAsync())
  2384. {
  2385. value = e.Current;
  2386. if(value == null) continue;
  2387. goto NEXT_LOOP;
  2388. }
  2389. return default;
  2390. NEXT_LOOP:
  2391. while (await e.MoveNextAsync())
  2392. {
  2393. var x = e.Current;
  2394. if( x == null) continue;
  2395. if (value < x)
  2396. {
  2397. value = x;
  2398. }
  2399. }
  2400. }
  2401. finally
  2402. {
  2403. if (e != null)
  2404. {
  2405. await e.DisposeAsync();
  2406. }
  2407. }
  2408. return value;
  2409. }
  2410. public static async UniTask<Int32?> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int32?> selector, CancellationToken cancellationToken)
  2411. {
  2412. Int32? value = default;
  2413. var e = source.GetAsyncEnumerator(cancellationToken);
  2414. try
  2415. {
  2416. while (await e.MoveNextAsync())
  2417. {
  2418. value = selector(e.Current);
  2419. if(value == null) continue;
  2420. goto NEXT_LOOP;
  2421. }
  2422. return default;
  2423. NEXT_LOOP:
  2424. while (await e.MoveNextAsync())
  2425. {
  2426. var x = selector(e.Current);
  2427. if( x == null) continue;
  2428. if (value < x)
  2429. {
  2430. value = x;
  2431. }
  2432. }
  2433. }
  2434. finally
  2435. {
  2436. if (e != null)
  2437. {
  2438. await e.DisposeAsync();
  2439. }
  2440. }
  2441. return value;
  2442. }
  2443. public static async UniTask<Int32?> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int32?>> selector, CancellationToken cancellationToken)
  2444. {
  2445. Int32? value = default;
  2446. var e = source.GetAsyncEnumerator(cancellationToken);
  2447. try
  2448. {
  2449. while (await e.MoveNextAsync())
  2450. {
  2451. value = await selector(e.Current);
  2452. if(value == null) continue;
  2453. goto NEXT_LOOP;
  2454. }
  2455. return default;
  2456. NEXT_LOOP:
  2457. while (await e.MoveNextAsync())
  2458. {
  2459. var x = await selector(e.Current);
  2460. if( x == null) continue;
  2461. if (value < x)
  2462. {
  2463. value = x;
  2464. }
  2465. }
  2466. }
  2467. finally
  2468. {
  2469. if (e != null)
  2470. {
  2471. await e.DisposeAsync();
  2472. }
  2473. }
  2474. return value;
  2475. }
  2476. public static async UniTask<Int32?> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int32?>> selector, CancellationToken cancellationToken)
  2477. {
  2478. Int32? value = default;
  2479. var e = source.GetAsyncEnumerator(cancellationToken);
  2480. try
  2481. {
  2482. while (await e.MoveNextAsync())
  2483. {
  2484. value = await selector(e.Current, cancellationToken);
  2485. if(value == null) continue;
  2486. goto NEXT_LOOP;
  2487. }
  2488. return default;
  2489. NEXT_LOOP:
  2490. while (await e.MoveNextAsync())
  2491. {
  2492. var x = await selector(e.Current, cancellationToken);
  2493. if( x == null) continue;
  2494. if (value < x)
  2495. {
  2496. value = x;
  2497. }
  2498. }
  2499. }
  2500. finally
  2501. {
  2502. if (e != null)
  2503. {
  2504. await e.DisposeAsync();
  2505. }
  2506. }
  2507. return value;
  2508. }
  2509. public static async UniTask<Int64?> MaxAsync(IUniTaskAsyncEnumerable<Int64?> source, CancellationToken cancellationToken)
  2510. {
  2511. Int64? value = default;
  2512. var e = source.GetAsyncEnumerator(cancellationToken);
  2513. try
  2514. {
  2515. while (await e.MoveNextAsync())
  2516. {
  2517. value = e.Current;
  2518. if(value == null) continue;
  2519. goto NEXT_LOOP;
  2520. }
  2521. return default;
  2522. NEXT_LOOP:
  2523. while (await e.MoveNextAsync())
  2524. {
  2525. var x = e.Current;
  2526. if( x == null) continue;
  2527. if (value < x)
  2528. {
  2529. value = x;
  2530. }
  2531. }
  2532. }
  2533. finally
  2534. {
  2535. if (e != null)
  2536. {
  2537. await e.DisposeAsync();
  2538. }
  2539. }
  2540. return value;
  2541. }
  2542. public static async UniTask<Int64?> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Int64?> selector, CancellationToken cancellationToken)
  2543. {
  2544. Int64? value = default;
  2545. var e = source.GetAsyncEnumerator(cancellationToken);
  2546. try
  2547. {
  2548. while (await e.MoveNextAsync())
  2549. {
  2550. value = selector(e.Current);
  2551. if(value == null) continue;
  2552. goto NEXT_LOOP;
  2553. }
  2554. return default;
  2555. NEXT_LOOP:
  2556. while (await e.MoveNextAsync())
  2557. {
  2558. var x = selector(e.Current);
  2559. if( x == null) continue;
  2560. if (value < x)
  2561. {
  2562. value = x;
  2563. }
  2564. }
  2565. }
  2566. finally
  2567. {
  2568. if (e != null)
  2569. {
  2570. await e.DisposeAsync();
  2571. }
  2572. }
  2573. return value;
  2574. }
  2575. public static async UniTask<Int64?> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Int64?>> selector, CancellationToken cancellationToken)
  2576. {
  2577. Int64? value = default;
  2578. var e = source.GetAsyncEnumerator(cancellationToken);
  2579. try
  2580. {
  2581. while (await e.MoveNextAsync())
  2582. {
  2583. value = await selector(e.Current);
  2584. if(value == null) continue;
  2585. goto NEXT_LOOP;
  2586. }
  2587. return default;
  2588. NEXT_LOOP:
  2589. while (await e.MoveNextAsync())
  2590. {
  2591. var x = await selector(e.Current);
  2592. if( x == null) continue;
  2593. if (value < x)
  2594. {
  2595. value = x;
  2596. }
  2597. }
  2598. }
  2599. finally
  2600. {
  2601. if (e != null)
  2602. {
  2603. await e.DisposeAsync();
  2604. }
  2605. }
  2606. return value;
  2607. }
  2608. public static async UniTask<Int64?> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Int64?>> selector, CancellationToken cancellationToken)
  2609. {
  2610. Int64? value = default;
  2611. var e = source.GetAsyncEnumerator(cancellationToken);
  2612. try
  2613. {
  2614. while (await e.MoveNextAsync())
  2615. {
  2616. value = await selector(e.Current, cancellationToken);
  2617. if(value == null) continue;
  2618. goto NEXT_LOOP;
  2619. }
  2620. return default;
  2621. NEXT_LOOP:
  2622. while (await e.MoveNextAsync())
  2623. {
  2624. var x = await selector(e.Current, cancellationToken);
  2625. if( x == null) continue;
  2626. if (value < x)
  2627. {
  2628. value = x;
  2629. }
  2630. }
  2631. }
  2632. finally
  2633. {
  2634. if (e != null)
  2635. {
  2636. await e.DisposeAsync();
  2637. }
  2638. }
  2639. return value;
  2640. }
  2641. public static async UniTask<Single?> MaxAsync(IUniTaskAsyncEnumerable<Single?> source, CancellationToken cancellationToken)
  2642. {
  2643. Single? value = default;
  2644. var e = source.GetAsyncEnumerator(cancellationToken);
  2645. try
  2646. {
  2647. while (await e.MoveNextAsync())
  2648. {
  2649. value = e.Current;
  2650. if(value == null) continue;
  2651. goto NEXT_LOOP;
  2652. }
  2653. return default;
  2654. NEXT_LOOP:
  2655. while (await e.MoveNextAsync())
  2656. {
  2657. var x = e.Current;
  2658. if( x == null) continue;
  2659. if (value < x)
  2660. {
  2661. value = x;
  2662. }
  2663. }
  2664. }
  2665. finally
  2666. {
  2667. if (e != null)
  2668. {
  2669. await e.DisposeAsync();
  2670. }
  2671. }
  2672. return value;
  2673. }
  2674. public static async UniTask<Single?> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Single?> selector, CancellationToken cancellationToken)
  2675. {
  2676. Single? value = default;
  2677. var e = source.GetAsyncEnumerator(cancellationToken);
  2678. try
  2679. {
  2680. while (await e.MoveNextAsync())
  2681. {
  2682. value = selector(e.Current);
  2683. if(value == null) continue;
  2684. goto NEXT_LOOP;
  2685. }
  2686. return default;
  2687. NEXT_LOOP:
  2688. while (await e.MoveNextAsync())
  2689. {
  2690. var x = selector(e.Current);
  2691. if( x == null) continue;
  2692. if (value < x)
  2693. {
  2694. value = x;
  2695. }
  2696. }
  2697. }
  2698. finally
  2699. {
  2700. if (e != null)
  2701. {
  2702. await e.DisposeAsync();
  2703. }
  2704. }
  2705. return value;
  2706. }
  2707. public static async UniTask<Single?> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Single?>> selector, CancellationToken cancellationToken)
  2708. {
  2709. Single? value = default;
  2710. var e = source.GetAsyncEnumerator(cancellationToken);
  2711. try
  2712. {
  2713. while (await e.MoveNextAsync())
  2714. {
  2715. value = await selector(e.Current);
  2716. if(value == null) continue;
  2717. goto NEXT_LOOP;
  2718. }
  2719. return default;
  2720. NEXT_LOOP:
  2721. while (await e.MoveNextAsync())
  2722. {
  2723. var x = await selector(e.Current);
  2724. if( x == null) continue;
  2725. if (value < x)
  2726. {
  2727. value = x;
  2728. }
  2729. }
  2730. }
  2731. finally
  2732. {
  2733. if (e != null)
  2734. {
  2735. await e.DisposeAsync();
  2736. }
  2737. }
  2738. return value;
  2739. }
  2740. public static async UniTask<Single?> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Single?>> selector, CancellationToken cancellationToken)
  2741. {
  2742. Single? value = default;
  2743. var e = source.GetAsyncEnumerator(cancellationToken);
  2744. try
  2745. {
  2746. while (await e.MoveNextAsync())
  2747. {
  2748. value = await selector(e.Current, cancellationToken);
  2749. if(value == null) continue;
  2750. goto NEXT_LOOP;
  2751. }
  2752. return default;
  2753. NEXT_LOOP:
  2754. while (await e.MoveNextAsync())
  2755. {
  2756. var x = await selector(e.Current, cancellationToken);
  2757. if( x == null) continue;
  2758. if (value < x)
  2759. {
  2760. value = x;
  2761. }
  2762. }
  2763. }
  2764. finally
  2765. {
  2766. if (e != null)
  2767. {
  2768. await e.DisposeAsync();
  2769. }
  2770. }
  2771. return value;
  2772. }
  2773. public static async UniTask<Double?> MaxAsync(IUniTaskAsyncEnumerable<Double?> source, CancellationToken cancellationToken)
  2774. {
  2775. Double? value = default;
  2776. var e = source.GetAsyncEnumerator(cancellationToken);
  2777. try
  2778. {
  2779. while (await e.MoveNextAsync())
  2780. {
  2781. value = e.Current;
  2782. if(value == null) continue;
  2783. goto NEXT_LOOP;
  2784. }
  2785. return default;
  2786. NEXT_LOOP:
  2787. while (await e.MoveNextAsync())
  2788. {
  2789. var x = e.Current;
  2790. if( x == null) continue;
  2791. if (value < x)
  2792. {
  2793. value = x;
  2794. }
  2795. }
  2796. }
  2797. finally
  2798. {
  2799. if (e != null)
  2800. {
  2801. await e.DisposeAsync();
  2802. }
  2803. }
  2804. return value;
  2805. }
  2806. public static async UniTask<Double?> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Double?> selector, CancellationToken cancellationToken)
  2807. {
  2808. Double? value = default;
  2809. var e = source.GetAsyncEnumerator(cancellationToken);
  2810. try
  2811. {
  2812. while (await e.MoveNextAsync())
  2813. {
  2814. value = selector(e.Current);
  2815. if(value == null) continue;
  2816. goto NEXT_LOOP;
  2817. }
  2818. return default;
  2819. NEXT_LOOP:
  2820. while (await e.MoveNextAsync())
  2821. {
  2822. var x = selector(e.Current);
  2823. if( x == null) continue;
  2824. if (value < x)
  2825. {
  2826. value = x;
  2827. }
  2828. }
  2829. }
  2830. finally
  2831. {
  2832. if (e != null)
  2833. {
  2834. await e.DisposeAsync();
  2835. }
  2836. }
  2837. return value;
  2838. }
  2839. public static async UniTask<Double?> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Double?>> selector, CancellationToken cancellationToken)
  2840. {
  2841. Double? value = default;
  2842. var e = source.GetAsyncEnumerator(cancellationToken);
  2843. try
  2844. {
  2845. while (await e.MoveNextAsync())
  2846. {
  2847. value = await selector(e.Current);
  2848. if(value == null) continue;
  2849. goto NEXT_LOOP;
  2850. }
  2851. return default;
  2852. NEXT_LOOP:
  2853. while (await e.MoveNextAsync())
  2854. {
  2855. var x = await selector(e.Current);
  2856. if( x == null) continue;
  2857. if (value < x)
  2858. {
  2859. value = x;
  2860. }
  2861. }
  2862. }
  2863. finally
  2864. {
  2865. if (e != null)
  2866. {
  2867. await e.DisposeAsync();
  2868. }
  2869. }
  2870. return value;
  2871. }
  2872. public static async UniTask<Double?> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Double?>> selector, CancellationToken cancellationToken)
  2873. {
  2874. Double? value = default;
  2875. var e = source.GetAsyncEnumerator(cancellationToken);
  2876. try
  2877. {
  2878. while (await e.MoveNextAsync())
  2879. {
  2880. value = await selector(e.Current, cancellationToken);
  2881. if(value == null) continue;
  2882. goto NEXT_LOOP;
  2883. }
  2884. return default;
  2885. NEXT_LOOP:
  2886. while (await e.MoveNextAsync())
  2887. {
  2888. var x = await selector(e.Current, cancellationToken);
  2889. if( x == null) continue;
  2890. if (value < x)
  2891. {
  2892. value = x;
  2893. }
  2894. }
  2895. }
  2896. finally
  2897. {
  2898. if (e != null)
  2899. {
  2900. await e.DisposeAsync();
  2901. }
  2902. }
  2903. return value;
  2904. }
  2905. public static async UniTask<Decimal?> MaxAsync(IUniTaskAsyncEnumerable<Decimal?> source, CancellationToken cancellationToken)
  2906. {
  2907. Decimal? value = default;
  2908. var e = source.GetAsyncEnumerator(cancellationToken);
  2909. try
  2910. {
  2911. while (await e.MoveNextAsync())
  2912. {
  2913. value = e.Current;
  2914. if(value == null) continue;
  2915. goto NEXT_LOOP;
  2916. }
  2917. return default;
  2918. NEXT_LOOP:
  2919. while (await e.MoveNextAsync())
  2920. {
  2921. var x = e.Current;
  2922. if( x == null) continue;
  2923. if (value < x)
  2924. {
  2925. value = x;
  2926. }
  2927. }
  2928. }
  2929. finally
  2930. {
  2931. if (e != null)
  2932. {
  2933. await e.DisposeAsync();
  2934. }
  2935. }
  2936. return value;
  2937. }
  2938. public static async UniTask<Decimal?> MaxAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, Decimal?> selector, CancellationToken cancellationToken)
  2939. {
  2940. Decimal? value = default;
  2941. var e = source.GetAsyncEnumerator(cancellationToken);
  2942. try
  2943. {
  2944. while (await e.MoveNextAsync())
  2945. {
  2946. value = selector(e.Current);
  2947. if(value == null) continue;
  2948. goto NEXT_LOOP;
  2949. }
  2950. return default;
  2951. NEXT_LOOP:
  2952. while (await e.MoveNextAsync())
  2953. {
  2954. var x = selector(e.Current);
  2955. if( x == null) continue;
  2956. if (value < x)
  2957. {
  2958. value = x;
  2959. }
  2960. }
  2961. }
  2962. finally
  2963. {
  2964. if (e != null)
  2965. {
  2966. await e.DisposeAsync();
  2967. }
  2968. }
  2969. return value;
  2970. }
  2971. public static async UniTask<Decimal?> MaxAwaitAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
  2972. {
  2973. Decimal? value = default;
  2974. var e = source.GetAsyncEnumerator(cancellationToken);
  2975. try
  2976. {
  2977. while (await e.MoveNextAsync())
  2978. {
  2979. value = await selector(e.Current);
  2980. if(value == null) continue;
  2981. goto NEXT_LOOP;
  2982. }
  2983. return default;
  2984. NEXT_LOOP:
  2985. while (await e.MoveNextAsync())
  2986. {
  2987. var x = await selector(e.Current);
  2988. if( x == null) continue;
  2989. if (value < x)
  2990. {
  2991. value = x;
  2992. }
  2993. }
  2994. }
  2995. finally
  2996. {
  2997. if (e != null)
  2998. {
  2999. await e.DisposeAsync();
  3000. }
  3001. }
  3002. return value;
  3003. }
  3004. public static async UniTask<Decimal?> MaxAwaitWithCancellationAsync<TSource>(IUniTaskAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, UniTask<Decimal?>> selector, CancellationToken cancellationToken)
  3005. {
  3006. Decimal? value = default;
  3007. var e = source.GetAsyncEnumerator(cancellationToken);
  3008. try
  3009. {
  3010. while (await e.MoveNextAsync())
  3011. {
  3012. value = await selector(e.Current, cancellationToken);
  3013. if(value == null) continue;
  3014. goto NEXT_LOOP;
  3015. }
  3016. return default;
  3017. NEXT_LOOP:
  3018. while (await e.MoveNextAsync())
  3019. {
  3020. var x = await selector(e.Current, cancellationToken);
  3021. if( x == null) continue;
  3022. if (value < x)
  3023. {
  3024. value = x;
  3025. }
  3026. }
  3027. }
  3028. finally
  3029. {
  3030. if (e != null)
  3031. {
  3032. await e.DisposeAsync();
  3033. }
  3034. }
  3035. return value;
  3036. }
  3037. }
  3038. }