コード例 #1
0
ファイル: SparseTwinIndex.cs プロジェクト: taha-islam/XTMF
        public static SparseTwinIndex <T> CreateTwinIndex(int[] first, int[] second, T[] data)
        {
            var length = data.Length;

            if (length == 0)
            {
                return(new SparseTwinIndex <T>(new SparseIndexing()
                {
                    Indexes = null
                }, null));
            }
            SortStruct[] indexes = new SortStruct[length];
            for (int i = 0; i < length; i++)
            {
                indexes[i].SparseSpaceFirst  = first[i];
                indexes[i].SparseSpaceSecond = second[i];
                indexes[i].DataSpace         = i;
            }
            Array.Sort(indexes, new CompareSortStruct());
            var processedIndexes = GenerateIndexes(indexes);

            T[][] Data;

            return(new SparseTwinIndex <T>(ConvertToIndexes(processedIndexes, out Data, data, indexes), Data)
            {
                Count = length
            });
        }
コード例 #2
0
                public int Compare(object x, object y)
                {
                    SortStruct x1 = x as SortStruct;

                    SortStruct y1 = y as SortStruct;

                    return(x1.ID > y1.ID ? 1 : -1);
                }
コード例 #3
0
ファイル: SparseArray.cs プロジェクト: dianatle/XTMF
        public static SparseArray <T> CreateSparseArray(Func <T, int> PlaceFunction, IList <T> data)
        {
            var length = data.Count;

            SortStruct[] indexes = new SortStruct[length];
            for (int i = 0; i < length; i++)
            {
                indexes[i].SparseSpace = PlaceFunction(data[i]);
                indexes[i].DataSpace   = i;
            }
            return(CreateSparseArray(data, length, indexes));
        }
コード例 #4
0
ファイル: SparseArray.cs プロジェクト: dianatle/XTMF
        public static SparseArray <T> CreateSparseArray(int[] sparseSpace, IList <T> data)
        {
            var length = data.Count;

            SortStruct[] indexes = new SortStruct[length];
            for (int i = 0; i < length; i++)
            {
                indexes[i].SparseSpace = sparseSpace[i];
                indexes[i].DataSpace   = i;
            }
            return(CreateSparseArray(data, length, indexes));
        }
コード例 #5
0
            public bool OnMenuItemClick(IMenuItem item)
            {
                if (!item.IsEnabled)
                {
                    return(false);
                }

                SortStruct s = parent.sorts[(int)parent.updated.Tag];

                s.Mode = (SortStruct.SortMode)item.ItemId;

                ((TextView)parent.updated).Text = item.TitleFormatted.ToString();
                return(true);
            }
コード例 #6
0
        public void AddNewSort()
        {
            for (int i = 0; i < isSorted.Count; ++i)
            {
                if (!isSorted[i])
                {
                    SortStruct s = new SortStruct(columns[i].ColumnId, SortStruct.SortMode.ASCENDING);

                    sorts.Add(s);
                    sortsList.AddView(MakeNewSortItem(sorts.Count - 1, s.ColumnId, s.Mode), sortsList.ChildCount - 1);
                    isSorted[i] = true;
                    break;
                }
            }
        }
コード例 #7
0
            public bool OnMenuItemClick(IMenuItem item)
            {
                if (!item.IsEnabled)
                {
                    return(false);
                }

                SortStruct s        = parent.sorts[(int)parent.updated.Tag];
                int        colIndex = parent.columns.FindIndex(C => C.ColumnId == s.ColumnId);

                parent.isSorted[colIndex] = false;

                s.ColumnId = parent.columns[item.ItemId].ColumnId;
                parent.isSorted[item.ItemId] = true;

                ((TextView)parent.updated).Text = item.TitleFormatted.ToString();
                return(true);
            }
コード例 #8
0
        public void RemoveSort(int index)
        {
            SortStruct removed = sorts[index];

            isSorted[sorts.IndexOf(removed)] = false;
            sortsList.RemoveViewAt(index);
            sorts.RemoveAt(index);

            for (int i = index; i < sortsList.ChildCount - 1; ++i)
            {
                View updated = sortsList.GetChildAt(i);

                TextView columnButton = updated.FindViewById <TextView>(Resource.Id.ViewSortColumn);
                columnButton.Tag = i;

                TextView sortTypeButton = updated.FindViewById <TextView>(Resource.Id.ViewSortType);
                sortTypeButton.Tag = i;

                View removeButton = updated.FindViewById(Resource.Id.ViewSortRemove);
                removeButton.Tag = i;
            }
        }
コード例 #9
0
ファイル: SparseTriIndex.cs プロジェクト: lunaxi7/XTMF
        public static SparseTriIndex <T> CreateSparseTriIndex(int[] first, int[] second, int[] third, T[] data)
        {
            var length = data.Length;

            if (length == 0)
            {
                // create a null tri indexed space
                return(new SparseTriIndex <T>());
            }
            var indexes = new SortStruct[length];

            // Copy everything into a struct for sanity
            for (var i = 0; i < length; i++)
            {
                indexes[i].SparseSpaceFirst  = first[i];
                indexes[i].SparseSpaceSecond = second[i];
                indexes[i].SparseSpaceThird  = third[i];
                indexes[i].DataSpace         = i;
            }
            Array.Sort(indexes, new CompareSortStruct());
            var processedIndexes = GenerateIndexes(indexes);

            return(new SparseTriIndex <T>(ConvertToIndexes(processedIndexes, out T[][][] localData, data, indexes), localData));
        }
コード例 #10
0
        private void Sort(int ColumnIndex, bool Ascending = true)
        {
            // Assume all rows are of same length - this is currently always the case.
            Column SelCol = CtrlStack.Children[ColumnIndex] as Column;

            if (SelCol != null)
            {
                SortStruct[] AllData = new SortStruct[SelCol.RowCount()];

                for (int Idx = 0; Idx < SelCol.RowCount(); Idx++)
                {
                    AllData[Idx].RowList    = new List <UIElement>();
                    AllData[Idx].SortingObj = SelCol.GetRowValue(Idx);
                }

                for (int ColIdx = 0; ColIdx < CtrlStack.Children.Count; ColIdx++)
                {
                    Column Col = CtrlStack.Children[ColIdx] as Column;

                    if (Col != null)
                    {
                        for (int RowIdx = 0; RowIdx < SelCol.RowCount(); RowIdx++)
                        {
                            AllData[RowIdx].RowList.Add(Col.GetRowControl(RowIdx));
                        }
                    }
                }

                IEnumerable <SortStruct> Data;

                Data = (Ascending) ? from d in AllData
                       orderby d.SortingObj ascending
                       select d
                                  : from d in AllData
                       orderby d.SortingObj descending
                       select d;

                for (int ColIdx = 0; ColIdx < CtrlStack.Children.Count; ColIdx++)
                {
                    Column Col = CtrlStack.Children[ColIdx] as Column;

                    if (Col != null)
                    {
                        for (int RowIdx = 0; RowIdx < Col.RowCount(); RowIdx++)
                        {
                            Col.SetRowControl(RowIdx, null);
                        }
                    }
                }

                int RIdx = 0;
                foreach (SortStruct st in Data)
                {
                    for (int ColIdx = 0; ColIdx < CtrlStack.Children.Count; ColIdx++)
                    {
                        Column Col = CtrlStack.Children[ColIdx] as Column;

                        if (Col != null)
                        {
                            Col.SetRowControl(RIdx, (Control)st.RowList[ColIdx]);
                        }
                    }
                    RIdx++;
                }
            }
        }