浏览代码

fix IComparable interface

use the buildin IComparable in C#
/zgh-devtools
xingweizhu 4 年前
当前提交
b32f81cd
共有 2 个文件被更改,包括 9 次插入25 次删除
  1. 15
      com.unity.uiwidgets/Runtime/widgets/animated_list.cs
  2. 19
      com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs

15
com.unity.uiwidgets/Runtime/widgets/animated_list.cs


while (min < max) {
int mid = min + ((max - min) >> 1);
T element = sortedList[mid];
int comp = element.compareTo(value);
int comp = element.CompareTo(value);
if (comp == 0) {
return mid;
}

}
}
public class _ActiveItem : Comparable<_ActiveItem> {
public class _ActiveItem : IComparable {
public _ActiveItem(
AnimationController controller,

public int itemIndex;
public int compareTo(_ActiveItem other) {
return itemIndex - other.itemIndex;
}
public int compare(Comparable<_ActiveItem> a, _ActiveItem b) {
return 0;
//throw new NotImplementedException();
public int CompareTo(object other) {
D.assert(GetType() == other.GetType());
return itemIndex - ((_ActiveItem)other).itemIndex;
}
}
public class AnimatedList : StatefulWidget {

19
com.unity.uiwidgets/Runtime/widgets/focus_traversal.cs


return sortedList;
}
}
public interface Comparable<T> {
int compareTo(T other);
int compare(Comparable<T> a, T b);
}
public abstract class FocusOrder : Diagnosticable , Comparable<FocusOrder> {
public abstract class FocusOrder : Diagnosticable , IComparable {
public int compareTo(FocusOrder other) {
public int CompareTo(object other) {
return doCompare(other);
}
public int compare(Comparable<FocusOrder> a, FocusOrder b) {
//throw new NotImplementedException();
return a.compareTo(b);
return doCompare((FocusOrder) other);
}
protected abstract int doCompare(FocusOrder other);

"Incompatible order types can't be compared. Use a FocusTraversalGroup to group " +
"similar orders together."
);
return a.order.compareTo(b.order);
return a.order.CompareTo(b.order);
});
return ordered.Select((_OrderedFocusInfo info) => info.node).Concat(unordered);
}

正在加载...
取消
保存