mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Refactor: Refactor baselib; merge Array_ and Bool_
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
public class GfmlDocPos implements CompareAble {
|
||||
import gplx.objects.lists.CompareAble;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
public class GfmlDocPos implements CompareAble {
|
||||
public String Path() {if (path == null) MakePath(); return path;} private String path;
|
||||
public int compareTo(Object obj) {
|
||||
/* Same: same coord (ex: 0_1 = 0_1)
|
||||
@@ -23,14 +25,14 @@ public class GfmlDocPos implements CompareAble {
|
||||
Less: lower level (ex: 0_1 < 0) or lower idx (ex: 0_1 < 0_0) */
|
||||
GfmlDocPos comp = (GfmlDocPos)obj;
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
if (i >= comp.ary.length) return CompareAble_.More; // more ary than comp and whatever ary they share are equal; must be more;
|
||||
if (i >= comp.ary.length) return CompareAbleUtl.More; // more ary than comp and whatever ary they share are equal; must be more;
|
||||
int origVal = ary[i];
|
||||
int compVal = comp.ary[i];
|
||||
if (origVal == compVal) continue; // indexes are equal; continue to next
|
||||
else if (origVal < compVal) return CompareAble_.Less;
|
||||
else if (origVal > compVal) return CompareAble_.More;
|
||||
else if (origVal < compVal) return CompareAbleUtl.Less;
|
||||
else if (origVal > compVal) return CompareAbleUtl.More;
|
||||
}
|
||||
if (ary.length < comp.ary.length) return CompareAble_.Less; // less ary than comp, and whatever ary they share are equal; must be less
|
||||
if (ary.length < comp.ary.length) return CompareAbleUtl.Less; // less ary than comp, and whatever ary they share are equal; must be less
|
||||
return Int_.Compare(idx, comp.idx); // compare idx
|
||||
}
|
||||
public GfmlDocPos NewClone() {return new GfmlDocPos(ary, idx);}
|
||||
|
||||
@@ -14,6 +14,7 @@ GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.objects.lists.CompareAbleUtl;
|
||||
interface GfmlScopeItm {
|
||||
String Key();
|
||||
GfmlDocPos DocPos();
|
||||
@@ -57,7 +58,7 @@ class GfmlScopeList {
|
||||
GfmlScopeItm rv = null;
|
||||
for (Object itemObj : list) {
|
||||
GfmlScopeItm itm = (GfmlScopeItm)itemObj;
|
||||
if (CompareAble_.Is(CompareAble_.More_or_same, pos, itm.DocPos()))
|
||||
if (CompareAbleUtl.Is(CompareAbleUtl.More_or_same, pos, itm.DocPos()))
|
||||
rv = itm;
|
||||
else
|
||||
break; // ASSUME: insertion is done in order; first lessThan means rest will also be lessThan
|
||||
|
||||
Reference in New Issue
Block a user