Пример #1
0
        public List <KeyValuePair <int, int> > FindRangesWithSameValues(List <IColumnElement> array)
        {
            List <KeyValuePair <int, int> > result = new List <KeyValuePair <int, int> >();

            IColumnElement currentName = array[0];
            int            key         = -1;

            for (int i = 1; i < array.Count; i++)
            {
                if (currentName.IsEqualTo(array[i]))
                {
                    if (key == -1)
                    {
                        key = i - 1;
                    }
                }
                else
                {
                    currentName = array[i];
                    if (key != -1)
                    {
                        result.Add(new KeyValuePair <int, int>(key, i - 1));
                        key = -1;
                    }
                }
            }

            // Logic to include last value if any
            if (key != -1)
            {
                result.Add(new KeyValuePair <int, int>(key, array.Count - 1));
            }

            return(result);
        }
Пример #2
0
            public bool IsLessThan(IColumnElement other)
            {
                Age otherAsName = other as Age;

                return(this.data < otherAsName.data);
            }
Пример #3
0
            public bool IsEqualTo(IColumnElement other)
            {
                Age otherAsName = other as Age;

                return(this.data == otherAsName.data);
            }
Пример #4
0
            public bool IsGreaterThan(IColumnElement other)
            {
                Age otherAsName = other as Age;

                return(this.data > otherAsName.data);
            }
Пример #5
0
            public bool IsLessThan(IColumnElement other)
            {
                Name otherAsName = other as Name;

                return(this.data.CompareTo(otherAsName.data) < 0);
            }
Пример #6
0
            public bool IsEqualTo(IColumnElement other)
            {
                Name otherAsName = other as Name;

                return(this.data.CompareTo(otherAsName.data) == 0);
            }
Пример #7
0
            public bool IsLessThan(IColumnElement other)
            {
                Weight otherAsName = other as Weight;

                return(this.data > otherAsName.data);                // Weight sorted in descending order
            }
Пример #8
0
            public bool IsEqualTo(IColumnElement other)
            {
                Weight otherAsName = other as Weight;

                return(this.data == otherAsName.data);
            }