Mercurial > hg > RemoteEditor > Eclipse
changeset 159:a5c56bff6359
*** empty log message ***
author | tkaito |
---|---|
date | Tue, 26 Aug 2008 19:45:26 +0900 |
parents | 55bc9f6b0691 |
children | e9047957acc2 |
files | src/pathfinder/mergetest/test/RepCommandOptimizeTest.java |
diffstat | 1 files changed, 52 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Tue Aug 26 19:09:15 2008 +0900 +++ b/src/pathfinder/mergetest/test/RepCommandOptimizeTest.java Tue Aug 26 19:45:26 2008 +0900 @@ -19,7 +19,7 @@ }; - String[] test2 = new String[test1.length]; + //String[] test2 = new String[test1.length]; static LinkedList<REPCommand> cmdlist = new LinkedList<REPCommand>(); Text text = new Text(); @@ -58,7 +58,58 @@ System.out.println("------------ Text -----------"); text.printAllText(); } + LinkedList<REPCommand> optimize(LinkedList<REPCommand> input){ + LinkedList<REPCommand> output = new LinkedList<REPCommand>(); + for(REPCommand r : input){ + optimizedAdd(output,r); + } + + return reverse(output); + + } + private LinkedList<REPCommand> reverse(LinkedList<REPCommand> outp) { + LinkedList<REPCommand> reverse = new LinkedList<REPCommand>(); + for(REPCommand r : outp){ + reverse.addFirst(r); + } + return reverse; + } + private void optimizedAdd(LinkedList<REPCommand> output, REPCommand r) { + switch(r.cmd){ + case REP.REPCMD_INSERT: + optimizedAddInsert(output,r);break; + case REP.REPCMD_DELETE: + optimizedAddDelete(output,r);break; + } + + } + private void optimizedAddDelete(LinkedList<REPCommand> output, REPCommand r) { + for(REPCommand s : output){ + switch(r.cmd){ + case REP.REPCMD_INSERT: + break; + case REP.REPCMD_DELETE: + break; + } + } + + } + private void optimizedAddInsert(LinkedList<REPCommand> output, REPCommand r) { + int lineno = r.lineno; + for(int i = 0; i < output.size(); i++){ + REPCommand s = output.get(i); + switch(s.cmd){ + case REP.REPCMD_INSERT: + break; + case REP.REPCMD_DELETE: + if(s.lineno == lineno){ + output.remove(s); + } + break; + } + } + } public static void main(String[] s){ RepCommandOptimizeTest rco = new RepCommandOptimizeTest();