mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.5.4.1
This commit is contained in:
@@ -29,6 +29,6 @@ public interface GfmlLxr extends GfoEvObj {
|
||||
class GfmlLxrRegy {
|
||||
public int Count() {return hash.Count();}
|
||||
public void Add(GfmlLxr lxr) {hash.Add(lxr.Key(), lxr);}
|
||||
public GfmlLxr Fetch(String key) {return (GfmlLxr)hash.Fetch(key);}
|
||||
HashAdp hash = HashAdp_.new_();
|
||||
public GfmlLxr Get_by(String key) {return (GfmlLxr)hash.Get_by(key);}
|
||||
Hash_adp hash = Hash_adp_.new_();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
public class GfmlObjList extends ListAdp_base {
|
||||
@gplx.New public GfmlObj FetchAt(int idx) {return (GfmlObj)FetchAt_base(idx);}
|
||||
public class GfmlObjList extends List_adp_base {
|
||||
@gplx.New public GfmlObj Get_at(int idx) {return (GfmlObj)Get_at_base(idx);}
|
||||
public void Add(GfmlObj tkn) {Add_base(tkn);}
|
||||
public void AddAt(GfmlObj tkn, int idx) {super.AddAt_base(idx, tkn);}
|
||||
public void Add_at(GfmlObj tkn, int idx) {super.AddAt_base(idx, tkn);}
|
||||
public void Del(GfmlObj tkn) {Del_base(tkn);}
|
||||
public static GfmlObjList new_() {return new GfmlObjList();} GfmlObjList() {}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GfmlTkn_ {
|
||||
@gplx.Internal protected static GfmlTkn composite_list_(String tknType, GfmlObjList list) {
|
||||
GfmlTkn[] ary = new GfmlTkn[list.Count()];
|
||||
for (int i = 0; i < list.Count(); i++)
|
||||
ary[i] = (GfmlTkn)list.FetchAt(i);
|
||||
ary[i] = (GfmlTkn)list.Get_at(i);
|
||||
return GfmlTkn_.composite_(tknType, ary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@ public class GfmlTrie {
|
||||
public String[] Symbols() {
|
||||
String[] rv = new String[symbols.Count()];
|
||||
for (int i = 0; i < rv.length; i++)
|
||||
rv[i] = String_.cast_(symbols.FetchAt(i));
|
||||
rv[i] = String_.cast_(symbols.Get_at(i));
|
||||
return rv;
|
||||
} OrderedHash symbols = OrderedHash_.new_();
|
||||
} Ordered_hash symbols = Ordered_hash_.new_();
|
||||
public int LastMatchCount; // PERF: prop is faster than method
|
||||
public Object FindMatch(CharStream stream) {
|
||||
Object result = null; int moveCount = 0; LastMatchCount = 0;
|
||||
IntObjHash_base link = rootLink;
|
||||
while (stream.AtMid()) {
|
||||
Object found = link.Fetch(stream.Cur());
|
||||
Object found = link.Get_by(stream.Cur());
|
||||
if (found == null) break; // found is null; can happen for false matches; ex: <!-- reg, and <!-* is cur; goes to <!- before exit
|
||||
LastMatchCount++;
|
||||
IntObjHash_base foundAsLink = IntObjHash_base_.as_(found);
|
||||
@@ -54,7 +54,7 @@ public class GfmlTrie {
|
||||
IntObjHash_base curLink = rootLink;
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
char c = ary[i];
|
||||
Object found = curLink.Fetch(c);
|
||||
Object found = curLink.Get_by(c);
|
||||
IntObjHash_base foundAsLink = IntObjHash_base_.as_(found);
|
||||
if (i == lastIndex) { // lastChar
|
||||
if (found != null) { // slot is occupied
|
||||
@@ -79,7 +79,7 @@ public class GfmlTrie {
|
||||
curLink = foundAsLink;
|
||||
}
|
||||
}
|
||||
symbols.AddReplace(symbol, symbol);
|
||||
symbols.Add_if_dupe_use_nth(symbol, symbol);
|
||||
}
|
||||
public void Del(String symbol) {
|
||||
char[] ary = String_.XtoCharAry(symbol); int lastIndex = ary.length - 1;
|
||||
@@ -88,7 +88,7 @@ public class GfmlTrie {
|
||||
for (int i = 0; i < ary.length; i++) {
|
||||
char c = ary[i];
|
||||
linkAry[i] = link;
|
||||
link = IntObjHash_base_.as_(link.Fetch(c));
|
||||
link = IntObjHash_base_.as_(link.Get_by(c));
|
||||
if (link == null) break; // c does not have nextHash; break
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class GfmlTrie {
|
||||
for (int i = lastIndex; i >= 0; i--) { // remove each char from hashes; must move backwards
|
||||
char c = ary[i];
|
||||
IntObjHash_base curLink = linkAry[i];
|
||||
Object found = curLink.Fetch(c);
|
||||
Object found = curLink.Get_by(c);
|
||||
IntObjHash_base foundAsLink = IntObjHash_base_.as_(found);
|
||||
if (nextHash != null && nextHash.Bay() != null) // occurs when long is dropped; ex: '<-' and '<'; '<-' dropped; <'s .Bay in '<-' chain must be transplanted to '<' .Bay
|
||||
curLink.Set(c, nextHash.Bay());
|
||||
|
||||
@@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.gfml; import gplx.*;
|
||||
class IntObjHash_base {
|
||||
public int Count() {return count;} int count;
|
||||
public boolean Has(int key) {return Fetch(key) != null;}
|
||||
public Object Fetch(int key) {
|
||||
public boolean Has(int key) {return Get_by(key) != null;}
|
||||
public Object Get_by(int key) {
|
||||
if (key < 0) throw Err_.new_("key must be >= 0").Add("key", key);
|
||||
if (key > maxKey) return null;
|
||||
Object[] subAry = FetchSubAry(key);
|
||||
|
||||
Reference in New Issue
Block a user