Esempio n. 1
0
        /// <summary>
        /// Removes and returns the object at the beginning of the Queue.
        /// </summary>
        /// <param name="Function">The Function object.</param>
        /// <returns>The object that is removed from the beginning of the Queue.</returns>
        public SFunction Dequeue()
        {
            if (Function.Length == 0)
            {
                return(new SFunction());
            }

            // Clone will return data and after resize it
            SFunction returnData = new SFunction();

            Fill(ref returnData, ref Function[0]);

            if (Function.Length == 1)
            {
                Clear();
            }
            else
            {
                // Clone main data and after resize it
                SFunction[] newData = new SFunction[Function.Length - 1];

                for (int index = 1; index < Function.Length; index++)
                {
                    Fill(ref newData[index - 1], ref Function[index]);
                }

                Function = new SFunction[newData.Length];
                Function = (SFunction[])newData.Clone();
            }

            return(returnData);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds an object to the end of the Queue.
        /// </summary>
        /// <param name="Function">The Function object.</param>
        /// <param name="target">The object to add to the Queue. The Function can be null.</param>
        public void Enqueue(SFunction target)
        {
            // Clone main data and after resize it
            SFunction[] newData = new SFunction[Function.Length + 1];
            Fill(ref newData[newData.Length - 1], ref target);

            if (Function.Length != 0)
            {
                for (int index = 0; index < Function.Length; index++)
                {
                    Fill(ref newData[index], ref Function[index]);
                }
            }

            Function = new SFunction[newData.Length];
            Function = (SFunction[])newData.Clone();
        }