public MyList <MyList <T> > getGroupsSameCompare(IComparer <T> _cmp) { MyList <T> copy_ = new MyList <T>(this); copy_.sortElts(_cmp); MyList <MyList <T> > groups_; groups_ = new MyList <MyList <T> >(); MyList <T> group_; group_ = new MyList <T>(); int i_ = MyList <T> .FIRST_INDEX; int j_ = i_; j_--; while (i_ < copy_.size()) { if (i_ > MyList <T> .FIRST_INDEX) { int res_ = _cmp.Compare(copy_.get(i_), copy_.get(j_)); if (res_ != 0) { groups_.Add(group_); group_ = new MyList <T>(); } } group_.Add(copy_.get(i_)); i_++; j_++; } groups_.Add(group_); return(groups_); }
public MyList <T> getReverse() { MyList <T> list_ = new MyList <T>(this); int i_ = FIRST_INDEX; int j_ = list_.size(); j_--; while (i_ < j_) { list_.swapIndexes(i_, j_); i_++; j_--; } return(list_); }
public static void sortComparable <T>(MyList <T> _list) where T : IComparable <T> { int size_ = _list.size(); for (int i = MyList <T> .FIRST_INDEX; i < size_; i++) { int iSecond_ = i + 1; for (int j = iSecond_; j < size_; j++) { int res_ = _list.get(i).CompareTo(_list.get(j)); if (res_ > 0) { T elt_ = _list[i]; _list[i] = _list[j]; _list[j] = elt_; } } } }
public static bool disjoint(MyList <StringList> _list) { int size_ = _list.size(); for (int i = MyList <object> .FIRST_INDEX; i < size_; i++) { for (int j = MyList <object> .FIRST_INDEX; j < size_; j++) { if (i == j) { continue; } if (!_list.get(i).disjoint(_list.get(j))) { return(false); } } } return(true); }