Ejemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// This method copy elements which satisfies parameters
        public Bilist <T> return_list_of_clones_by_criteria(T origin)
        {
            Bilist <T> cloned_list = new Bilist <T>();

            Bidilist_elements <T> wp = this.start;

            while (wp != null)
            {
                if (wp.getData().CompareTo(origin) == 0)
                {
                    T clo = (T)wp.getData().Clone();
                    cloned_list.add_element_end(clo);
                }
                wp = wp.getNext();
            }

            return(cloned_list);
        }
Ejemplo n.º 2
0
/// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //Display the result

        public void output()
        {
            Bidilist_elements <T> curr_elem = this.start;

            while (curr_elem != null)
            {
                Console.WriteLine("Your current element data: {0}", curr_elem.getData());

                curr_elem = curr_elem.getNext();
            }
        }
Ejemplo n.º 3
0
        private T GetDataAt(long i)
        {
            if ((i < 0) || (i > this.amount_of_elements))
            {
                throw new IndexOutOfRangeException();
            }
            //   return default(T);

            else
            {
                Bidilist_elements <T> wp = this.start;
                for (long k = 0; k < i; k++)
                {
                    wp = wp.getNext();
                }
                return(wp.getData());
            }
        }
Ejemplo n.º 4
0
        // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// Method of getting new list, starting from the last element
        public Bilist <T> new_List_from_end(long N)
        {
            Bilist <T> reverse_list = new Bilist <T>();

            if (N > this.amount_of_elements)
            {
                return(null);
            }

            Bidilist_elements <T> WP = this.end;

            for (long i = 0; i < N; i++)
            {
                T clo = (T)WP.getData().Clone();
                reverse_list.add_element_start(clo);
                WP = WP.getPrev();
            }
            return(reverse_list);
        }
Ejemplo n.º 5
0
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Deleting element which have same parameters
        public void remove_elements_like(T origin)
        {
            Bidilist_elements <T> wp = this.start;
            long counter             = 0;

            while (wp != null)
            {
                if (wp.getData().CompareTo(origin) == 0)
                {
                    break;
                }
                wp = wp.getNext();
                counter++;
            }

            if (wp != null)  // we have finished finding with result
            {
                this.remove_elements_at(counter);
            }
        }