PopAny() public method

Selects a random item from the list and removes it.
public PopAny ( ) : object
return object
コード例 #1
0
        public Array ToShuffledArray(Type elementType)
        {
            List  copy   = new List(ToArray());
            Array target = Array.CreateInstance(elementType, copy.Count);

            for (int i = 0; i < target.Length; ++i)
            {
                target.SetValue(copy.PopAny(), i);
            }
            return(target);
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 public Array Choose(int count)
 {
     if (_list.Count > count)
     {
         List     copy  = new List(_list);
         object[] items = new object[count];
         for (int i = 0; i < count; ++i)
         {
             items[i] = copy.PopAny();
         }
         return(items);
     }
     else
     {
         return(ToShuffledArray());
     }
 }
コード例 #3
0
ファイル: List.cs プロジェクト: bamboo/Bamboo.Prevalence
		/// <summary>
		/// 
		/// </summary>
		public Array Choose(int count)
		{
			if (_list.Count > count)
			{
				List copy = new List(_list);
				object[] items = new object[count];
				for (int i=0; i<count; ++i)
				{
					items[i] = copy.PopAny();
				}
				return items;
			}
			else
			{
				return ToShuffledArray();
			}
		}
コード例 #4
0
ファイル: List.cs プロジェクト: bamboo/Bamboo.Prevalence
		public Array ToShuffledArray(Type elementType)
		{
			List copy = new List(ToArray());
			Array target = Array.CreateInstance(elementType, copy.Count);
			for (int i=0; i<target.Length; ++i)
			{
				target.SetValue(copy.PopAny(), i);
			}
			return target;
		}