@@ -229,46 +229,74 @@ public static T ChooseOneE<T>(params T[] args) // Ellipsis
229229 {
230230 return ChooseOne ( args ) ;
231231 }
232- public static T ChooseOne < T > ( ICollection < T > lst )
232+ public static T ChooseOne < T > ( IEnumerable < T > args )
233233 {
234- if ( lst == null || lst . Count == 0 )
234+ return ChooseOne ( args . ToList ( ) ) ;
235+ }
236+ public static T ChooseOne < T > ( ICollection < T > args )
237+ {
238+ if ( args == null || args . Count == 0 )
235239 return default ;
236240
237- int index = Range ( 0 , lst . Count ) ;
241+ int index = Range ( 0 , args . Count ) ;
238242
239- return lst . ElementAt ( index ) ;
243+ return args . ElementAt ( index ) ;
240244 }
241- public static List < T > Choose < T > ( int size , ICollection < T > lst )
245+ public static KeyValuePair < T , K > ChooseOneE < T , K > ( params KeyValuePair < T , K > [ ] args ) // Ellipsis
246+ {
247+ return ChooseOne ( args ) ;
248+ }
249+ public static KeyValuePair < T , K > ChooseOne < T , K > ( IEnumerable < KeyValuePair < T , K > > args ) // Ellipsis
250+ {
251+ return ChooseOne ( args . ToList ( ) ) ;
252+ }
253+ public static KeyValuePair < T , K > ChooseOne < T , K > ( ICollection < KeyValuePair < T , K > > args )
254+ {
255+ if ( args == null || args . Count == 0 )
256+ return default ;
257+
258+ int index = Range ( 0 , args . Count ) ;
259+
260+ return args . ElementAt ( index ) ;
261+ }
262+
263+ /// <summary>
264+ /// Choose multiple.
265+ /// </summary>
266+ public static List < T > ChooseE < T > ( int size , params T [ ] args ) // Ellipsis
267+ {
268+ return Choose ( size , args ) ;
269+ }
270+ public static List < T > Choose < T > ( int size , IEnumerable < T > args )
271+ {
272+ return Choose ( size , args . ToList ( ) ) ;
273+ }
274+ public static List < T > Choose < T > ( int size , ICollection < T > args )
242275 {
243276 List < T > chosen = new ( ) ;
244277
245278 JCS_Loop . Times ( size , ( ) =>
246279 {
247- chosen . Add ( ChooseOne ( lst ) ) ;
280+ chosen . Add ( ChooseOne ( args ) ) ;
248281 } ) ;
249282
250283 return chosen ;
251284 }
252- public static KeyValuePair < T , K > ChooseOneE < T , K > ( params KeyValuePair < T , K > [ ] args ) // Ellipsis
285+ public static List < KeyValuePair < T , K > > ChooseE < T , K > ( int size , params KeyValuePair < T , K > [ ] args )
253286 {
254- return ChooseOne ( args ) ;
287+ return Choose ( size , args ) ;
255288 }
256- public static KeyValuePair < T , K > ChooseOne < T , K > ( ICollection < KeyValuePair < T , K > > dict )
289+ public static List < KeyValuePair < T , K > > Choose < T , K > ( int size , IEnumerable < KeyValuePair < T , K > > args )
257290 {
258- if ( dict == null || dict . Count == 0 )
259- return default ;
260-
261- int index = Range ( 0 , dict . Count ) ;
262-
263- return dict . ElementAt ( index ) ;
291+ return Choose ( size , args . ToList ( ) ) ;
264292 }
265- public static List < KeyValuePair < T , K > > Choose < T , K > ( int size , ICollection < KeyValuePair < T , K > > dict )
293+ public static List < KeyValuePair < T , K > > Choose < T , K > ( int size , ICollection < KeyValuePair < T , K > > args )
266294 {
267295 List < KeyValuePair < T , K > > chosen = new ( ) ;
268296
269297 JCS_Loop . Times ( size , ( ) =>
270298 {
271- chosen . Add ( ChooseOne ( dict ) ) ;
299+ chosen . Add ( ChooseOne ( args ) ) ;
272300 } ) ;
273301
274302 return chosen ;
0 commit comments