示例#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);
            }