CopyTo() public method

public CopyTo ( Array array, int index ) : void
array Array
index int
return void
Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //New Queue of Integers

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(5);
            queue.Enqueue(10);
            queue.Enqueue(15);
            queue.Enqueue(20);

            /*Create new array with
            length equal to Queue's element count*/

            int[] array = new int[queue.Count];

            //Copy the Queue to the Array
            queue.CopyTo(array, 0);

            //Loop through and display int[] in order
            Console.WriteLine("Array: ");

            for (int i=0; i < array.Length; i++)
            {
                Console.WriteLine(array[i]);
            }

            //Loop through int array in reverse order

            Console.WriteLine("Array reverse order: ");
            for (int i = array.Length -1; i >= 0; i--)
            {
                Console.WriteLine(array[i]);

            }
        }
Ejemplo n.º 2
0
 static public int CopyTo(IntPtr l)
 {
     try {
         System.Collections.Queue self = (System.Collections.Queue)checkSelf(l);
         System.Array             a1;
         checkType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         self.CopyTo(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 3
0
 static int CopyTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         System.Collections.Queue obj  = (System.Collections.Queue)ToLua.CheckObject(L, 1, typeof(System.Collections.Queue));
         System.Array             arg0 = (System.Array)ToLua.CheckObject(L, 2, typeof(System.Array));
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.CopyTo(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 4
0
 public override void CopyTo(Array array, int arrayIndex)
 {
     lock (root) {
         _q.CopyTo(array, arrayIndex);
     }
 }
Ejemplo n.º 5
0
		public DirectoryInfo[] GetDirectories (string searchPattern, SearchOption searchOption)
		{
			switch (searchOption) {
			case SearchOption.TopDirectoryOnly:
				return GetDirectories (searchPattern);
			case SearchOption.AllDirectories:
				Queue workq = new Queue(GetDirectories(searchPattern));
				Queue doneq = new Queue();
				while (workq.Count > 0)
					{
						DirectoryInfo cinfo = (DirectoryInfo) workq.Dequeue();
						DirectoryInfo[] cinfoDirs = cinfo.GetDirectories(searchPattern);
						foreach (DirectoryInfo i in cinfoDirs) workq.Enqueue(i);
						doneq.Enqueue(cinfo);
					}

				DirectoryInfo[] infos = new DirectoryInfo[doneq.Count];
				doneq.CopyTo(infos, 0);
				return infos;
			default:
				string msg = Locale.GetText ("Invalid enum value '{0}' for '{1}'.", searchOption, "SearchOption");
				throw new ArgumentOutOfRangeException ("searchOption", msg);
			}
		}	
Ejemplo n.º 6
0
 public override void CopyTo(Array array, int index)
 {
     lock (queue) {
         queue.CopyTo(array, index);
     }
 }