コード例 #1
0
        public static JList <T> operator -(JList <T> listA, JList <T> listB)
        {
            JList <T> output     = new JList <T>();
            int       indexFound = listA.Find(listB);

            if (indexFound != -1)
            {
                int indexFoundEnd = indexFound + listB.Count - 1;
                for (int i = 0; i < listA.Count; i++)
                {
                    if (i < indexFound || i > indexFoundEnd)
                    {
                        output.Add(listA[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < listA.Count; i++)
                {
                    output.Add(listA[i]);
                }
            }

            return(output);
        }
コード例 #2
0
        public int Find(JList <T> findJList)
        {
            int index           = -2;
            int searchFromIndex = 0;

            do
            {
                int foundIndex = Find(findJList[0], searchFromIndex);
                if (foundIndex != -1 && foundIndex + findJList.count - 1 < count)
                {
                    int findJListIndex = 1;

                    for (int i = foundIndex + 1; i < foundIndex + findJList.Count; i++, findJListIndex++)
                    {
                        index = foundIndex;

                        if (!data[i].Equals(findJList[findJListIndex]))
                        {
                            searchFromIndex = foundIndex + 1;
                            index           = -2;
                            break;
                        }
                    }
                }
                else
                {
                    index = -1;
                }
            } while (index == -2);

            return(index);
        }
コード例 #3
0
        public static JList <T> operator +(JList <T> listA, JList <T> listB)
        {
            JList <JList <T> > jlists = new JList <JList <T> >();
            JList <T>          output = new JList <T>();

            jlists.Add(listA);
            jlists.Add(listB);

            for (int i = 0; i < jlists.Count; i++)
            {
                for (int j = 0; j < jlists[i].Count; j++)
                {
                    output.Add(jlists[i][j]);
                }
            }

            return(output);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            JList <string[]> data = new JList <string[]>()
            {
                new string[] { "A", "B", "C" },
                new string[] { "1", "2" },
                new string[] { "x", "yyyy", "zzz", "final" },
            };

            foreach (var array in data)
            {
                Console.WriteLine();

                foreach (var item in array)
                {
                    Console.Write(" ");
                    Console.Write(item);
                }
            }
        }