Skip to content

Commit c010852

Browse files
committed
removed LinkedLists because they are apparently almost always worse than ArrayLists. Eliminated type ambiguity in many of the RPC methods and argument/return types, which supposedly reduces code size. Started implementing versions handling of negated propositions.
1 parent 2a3cf73 commit c010852

18 files changed

+105
-105
lines changed

Implementation Notes.odt

-1.83 KB
Binary file not shown.

src/org/argmap/client/ArgMap.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import com.google.gwt.core.client.EntryPoint;
66
import com.google.gwt.core.client.GWT;
7-
import com.google.gwt.core.client.RunAsyncCallback;
87
import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
8+
import com.google.gwt.core.client.RunAsyncCallback;
99
import com.google.gwt.dom.client.Style;
1010
import com.google.gwt.event.logical.shared.SelectionEvent;
1111
import com.google.gwt.event.logical.shared.SelectionHandler;
@@ -22,9 +22,10 @@
2222
import com.google.gwt.user.client.ui.TabLayoutPanel;
2323
import com.google.gwt.user.client.ui.Widget;
2424

25+
//TODO: test opening negated links in versions mode (probably won't work!!!)
26+
//TODO: fix versions mode formating
2527
//TODO: do some basic testing of versioning of deleted top level nodes
2628
//TODO: versioning root node with no modifications/adds throws exception because of empty change list
27-
//TODO: test negated links in versions mode (probably won't work!!!)
2829
/*TODO: fix exceptions when opening circular links in versions mode and continue testings version mode's handling of circular linking*/
2930
/*TODO: track down exceptions in ModeVersion (unrelated to circular linking)*/
3031
/*TODO: a proposition tree begins at time A. At time C a pre-existing node is linked into the proposition tree.
@@ -263,8 +264,8 @@ public void onSuccess() {
263264
public void onFailure(Throwable reason) {
264265
ArgMap.messageTimed("Code download failed",
265266
MessageType.ERROR);
266-
Log.log("am.sv.a.of", "Code download failed"
267-
+ reason.toString());
267+
Log.log("am.sv.a.of",
268+
"Code download failed" + reason.toString());
268269
}
269270
});
270271
}
@@ -403,8 +404,7 @@ public void onUncaughtException(Throwable e) {
403404
} catch (Exception handlerException) {
404405
}
405406
GWT.log("Uncaught Exception", e);
406-
if (Log.on)
407-
Log.finishOpenLogs();
407+
if (Log.on) Log.finishOpenLogs();
408408
}
409409

410410
public ModeEdit getModeEdit() {

src/org/argmap/client/ArgMapService.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public void unlinkProp(Long parentArgID, Long propositionID)
4141
public class PartialTrees implements Serializable {
4242
/* added to suppress warnings */
4343
private static final long serialVersionUID = 1L;
44-
public List<Long> rootIDs = new ArrayList<Long>();
45-
public Map<Long, Node> nodes = new HashMap<Long, Node>();
46-
public Map<Long, Integer> ratings = new HashMap<Long, Integer>();
44+
public ArrayList<Long> rootIDs = new ArrayList<Long>();
45+
public HashMap<Long, Node> nodes = new HashMap<Long, Node>();
46+
public HashMap<Long, Integer> ratings = new HashMap<Long, Integer>();
4747

4848
@Override
4949
public String toString() {
@@ -78,15 +78,15 @@ public PartialTrees replaceWithLinkAndGet(Long parentArgID,
7878
public class NodesWithHistory implements Serializable {
7979
/* added to suppress warnings */
8080
private static final long serialVersionUID = 1L;
81-
public Map<Long, Node> nodes;
81+
public HashMap<Long, Node> nodes;
8282
public SortedMap<Date, Change> changes;
8383
}
8484

8585
public class NodeWithChanges implements Serializable {
8686
private static final long serialVersionUID = 1L;
8787
public Node node;
8888
public NodeChanges nodeChanges;
89-
public Map<Long, Proposition> unlinkedLinks = new HashMap<Long, Proposition>();
89+
public HashMap<Long, Proposition> unlinkedLinks = new HashMap<Long, Proposition>();
9090
}
9191

9292
public PartialTrees getNodesChildren(List<Long> nodeIDs, int depth)
@@ -100,14 +100,14 @@ public Map<Long, NodeWithChanges> getArgsWithChanges(List<Long> argIDs)
100100

101101
public class NodeChangesMapsAndRootChanges implements Serializable {
102102
public NodeChangesMaps nodeChangesMaps = new NodeChangesMaps();
103-
public List<Change> rootChanges = new ArrayList<Change>();
103+
public ArrayList<Change> rootChanges = new ArrayList<Change>();
104104
}
105105

106106
public class NodeChangesMaps implements Serializable {
107107
private static final long serialVersionUID = 1L;
108-
public Map<Long, NodeChanges> argChanges = new HashMap<Long, NodeChanges>();
109-
public Map<Long, NodeChanges> propChanges = new HashMap<Long, NodeChanges>();
110-
public Map<Long, Proposition> unlinkedLinks = new HashMap<Long, Proposition>();
108+
public HashMap<Long, NodeChanges> argChanges = new HashMap<Long, NodeChanges>();
109+
public HashMap<Long, NodeChanges> propChanges = new HashMap<Long, NodeChanges>();
110+
public HashMap<Long, Proposition> unlinkedLinks = new HashMap<Long, Proposition>();
111111

112112
@Override
113113
public String toString() {
@@ -134,7 +134,7 @@ public String toString() {
134134
public class DateAndChildIDs implements Serializable {
135135
private static final long serialVersionUID = 1L;
136136
public Date date;
137-
public Set<Long> childIDs;
137+
public HashSet<Long> childIDs;
138138

139139
@Override
140140
public String toString() {
@@ -157,17 +157,18 @@ public DateAndChildIDs(Node node) {
157157
}
158158
}
159159

160-
public PartialTrees getUpToDateNodes(Map<Long, DateAndChildIDs> propInfo,
161-
Map<Long, DateAndChildIDs> argInfo);
160+
public PartialTrees getUpToDateNodes(
161+
HashMap<Long, DateAndChildIDs> propInfo,
162+
HashMap<Long, DateAndChildIDs> argInfo);
162163

163-
public NodeChangesMaps getChanges(List<Long> propIDs, List<Long> argIDs)
164-
throws ServiceException;
164+
public NodeChangesMaps getChanges(ArrayList<Long> propIDs,
165+
ArrayList<Long> argIDs) throws ServiceException;
165166

166167
public NodeChangesMapsAndRootChanges getChangesForDeletedRootProps()
167168
throws ServiceException;
168169

169170
public PartialTrees searchProps(String searchString, String searchName,
170-
int resultLimit, List<Long> filerNodeIDs,
171+
int resultLimit, ArrayList<Long> filerNodeIDs,
171172
Double percentTermsMatching) throws ServiceException;
172173

173174
public PartialTrees continueSearchProps(String searchName)

src/org/argmap/client/ArgMapServiceAsync.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.argmap.client;
22

3+
import java.util.ArrayList;
4+
import java.util.HashMap;
35
import java.util.List;
46
import java.util.Map;
57

@@ -27,9 +29,6 @@ void unlinkProp(Long parentArgID, Long propositionID,
2729

2830
void updateArg(Long argID, String content, AsyncCallback<Void> callback);
2931

30-
void getChanges(List<Long> propIDs, List<Long> argIDs,
31-
AsyncCallback<NodeChangesMaps> callback);
32-
3332
void deleteArg(Long argID, AsyncCallback<Void> callback);
3433

3534
void logClientException(String exceptionStr, AsyncCallback<Void> callback);
@@ -50,10 +49,6 @@ void addProp(Long parentArgID, int position, String content,
5049
void continueSearchProps(String searchName,
5150
AsyncCallback<PartialTrees> callback);
5251

53-
void getUpToDateNodes(Map<Long, DateAndChildIDs> propInfo,
54-
Map<Long, DateAndChildIDs> argInfo,
55-
AsyncCallback<PartialTrees> callback);
56-
5752
void getRootProps(int depthLimit, AsyncCallback<PartialTrees> callback);
5853

5954
void getNodesChildren(List<Long> nodeIDs, int depth,
@@ -72,7 +67,14 @@ void replaceWithLinkAndGet(Long parentArgID, Long linkPropID,
7267
void getChangesForDeletedRootProps(
7368
AsyncCallback<NodeChangesMapsAndRootChanges> callback);
7469

70+
void getUpToDateNodes(HashMap<Long, DateAndChildIDs> propInfo,
71+
HashMap<Long, DateAndChildIDs> argInfo,
72+
AsyncCallback<PartialTrees> callback);
73+
74+
void getChanges(ArrayList<Long> propIDs, ArrayList<Long> argIDs,
75+
AsyncCallback<NodeChangesMaps> callback);
76+
7577
void searchProps(String searchString, String searchName, int resultLimit,
76-
List<Long> filerNodeIDs, Double percentTermsMatching,
78+
ArrayList<Long> filerNodeIDs, Double percentTermsMatching,
7779
AsyncCallback<PartialTrees> callback);
7880
}

src/org/argmap/client/Argument.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ public String toString() {
4343
return buffer.toString();
4444
}
4545

46-
/* transient public Long aboutPropID; */
47-
/*
48-
* @Transient public List<Proposition> props = new
49-
* LinkedList<Proposition>();
50-
*/
51-
5246
public Argument() {
5347
}
5448

src/org/argmap/client/Change.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ public enum ChangeType {
8383

8484
public int propLinkCount;
8585

86+
public boolean propNegated;
87+
8688
/*
8789
* For change type: PROP_MODIFICATION content refers to the proposition
8890
* content

src/org/argmap/client/Log.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.argmap.client;
22

3-
import java.util.LinkedList;
3+
import java.util.ArrayList;
44
import java.util.List;
55
import java.util.Map;
66
import java.util.Map.Entry;
@@ -9,7 +9,7 @@
99

1010
public class Log {
1111
public static final boolean on = true;
12-
private static final List<Log> openLogs = new LinkedList<Log>();
12+
private static final List<Log> openLogs = new ArrayList<Log>();
1313

1414
private boolean immediatePrint;
1515
private int indent;

src/org/argmap/client/ModeEdit.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
import com.google.gwt.user.client.ui.HTMLTable;
4444
import com.google.gwt.user.client.ui.Label;
4545
import com.google.gwt.user.client.ui.PopupPanel;
46+
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
4647
import com.google.gwt.user.client.ui.ResizeComposite;
4748
import com.google.gwt.user.client.ui.ScrollPanel;
4849
import com.google.gwt.user.client.ui.SplitLayoutPanel;
4950
import com.google.gwt.user.client.ui.TextBox;
5051
import com.google.gwt.user.client.ui.Tree;
5152
import com.google.gwt.user.client.ui.TreeItem;
5253
import com.google.gwt.user.client.ui.VerticalPanel;
53-
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
5454

5555
public class ModeEdit extends ResizeComposite implements KeyUpHandler,
5656
OpenHandler<TreeItem>, CloseHandler<TreeItem>,
@@ -279,8 +279,7 @@ public void onSuccess() {
279279
// propView.logNodeRecursive(0, "em.em.cb", true);
280280
}
281281
tree.resetState();
282-
if (Log.on)
283-
tree.logTree(log);
282+
if (Log.on) tree.logTree(log);
284283

285284
updateTimer.start();
286285
log.finish();
@@ -343,10 +342,10 @@ private void getUpdatesAndApply() {
343342
"strange: startTime == null on getUpdatesAndApply()");
344343
}
345344

346-
Map<Long, DateAndChildIDs> propsInfo = new HashMap<Long, DateAndChildIDs>();
345+
HashMap<Long, DateAndChildIDs> propsInfo = new HashMap<Long, DateAndChildIDs>();
347346

348347
loadNodeInfo(loadedProps, propsInfo);
349-
Map<Long, DateAndChildIDs> argsInfo = new HashMap<Long, DateAndChildIDs>();
348+
HashMap<Long, DateAndChildIDs> argsInfo = new HashMap<Long, DateAndChildIDs>();
350349
loadNodeInfo(loadedArgs, argsInfo);
351350

352351
ServerComm.getUpdates(propsInfo, argsInfo,
@@ -389,9 +388,7 @@ public void call(PartialTrees results) {
389388
List<ViewProp> viewProps = new ArrayList<ViewProp>(
390389
loadedProps.get(node.id));
391390
for (ViewProp viewProp : viewProps) {
392-
log
393-
.logln("prossesing ViewProp:"
394-
+ viewProp);
391+
log.logln("prossesing ViewProp:" + viewProp);
395392
updateNode(viewProp, node, results);
396393
}
397394
} else if (node instanceof Argument) {
@@ -746,10 +743,9 @@ public void call(PartialTrees trees) {
746743
}
747744
});
748745
} else {
749-
ArgMap
750-
.messageTimed(
751-
"Cannot link to existing proposition when proposition currently being edited has children",
752-
MessageType.ERROR);
746+
ArgMap.messageTimed(
747+
"Cannot link to existing proposition when proposition currently being edited has children",
748+
MessageType.ERROR);
753749
}
754750
}
755751

@@ -770,7 +766,7 @@ public void sideSearch(ViewPropEdit viewProp) {
770766
String searchString = viewProp.getTextAreaContent().trim();
771767
if (!searchString.equals("") && viewProp.getChildCount() == 0
772768
/* && !viewProp.deleted */) {
773-
List<Long> filterIDs = new ArrayList<Long>();
769+
ArrayList<Long> filterIDs = new ArrayList<Long>();
774770
filterIDs.addAll(viewProp.getAncestorIDs());
775771
if (viewProp.getParent() != null) {
776772
filterIDs.addAll(viewProp.getParent().getChildIDs());
@@ -1049,8 +1045,7 @@ public void run() {
10491045
}
10501046

10511047
schedule(currentFrequency);
1052-
if (on)
1053-
getUpdatesAndApply();
1048+
if (on) getUpdatesAndApply();
10541049
}
10551050

10561051
public void start() {
@@ -1320,8 +1315,8 @@ public void onOpen(OpenEvent<TreeItem> event) {
13201315
if (!source.isLoaded()) {
13211316
loadFromServer(source, 2, 1);
13221317
} else {
1323-
List<ViewNode> list = new ArrayList<ViewNode>(source
1324-
.getChildCount());
1318+
List<ViewNode> list = new ArrayList<ViewNode>(
1319+
source.getChildCount());
13251320
for (int i = 0; i < source.getChildCount(); i++) {
13261321
if (!source.getChild(i).isLoaded()) {
13271322
list.add(source.getChild(i));

src/org/argmap/client/ModeVersions.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.Collections;
66
import java.util.Date;
77
import java.util.HashMap;
8-
import java.util.LinkedList;
98
import java.util.List;
109
import java.util.Map;
1110

@@ -217,8 +216,8 @@ public void displayVersions() {
217216
if (treeClone != null) {
218217
treePanel.remove(treeClone);
219218
}
220-
List<Proposition> props = new LinkedList<Proposition>();
221-
List<Argument> args = new LinkedList<Argument>();
219+
List<Proposition> props = new ArrayList<Proposition>();
220+
List<Argument> args = new ArrayList<Argument>();
222221
editMode.getOpenPropsAndArgs(props, args);
223222
ServerComm.getChanges(props, args,
224223
new ServerComm.LocalCallback<NodeChangesMaps>() {

src/org/argmap/client/Node.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.argmap.client;
22

33
import java.io.Serializable;
4+
import java.util.ArrayList;
45
import java.util.Date;
5-
import java.util.LinkedList;
66
import java.util.List;
77

88
import javax.persistence.Id;
@@ -11,18 +11,19 @@
1111

1212
@Cached
1313
public class Node implements Serializable {
14-
/** to suppress warnings... */
14+
/** to suppress warnings... */
1515
private static final long serialVersionUID = 1L;
16-
17-
/* remember if you change the name of a field you have to update
18-
* the server queries: they operate on fields specified by strings
19-
* that are not checked at compile time.
16+
17+
/*
18+
* remember if you change the name of a field you have to update the server
19+
* queries: they operate on fields specified by strings that are not checked
20+
* at compile time.
2021
*/
2122
@Id
2223
public Long id;
2324
public String content = "";
24-
public List<Long> childIDs = new LinkedList<Long>();
25-
25+
public List<Long> childIDs = new ArrayList<Long>();
26+
2627
public Date updated;
2728
transient public Date created;
2829
}

0 commit comments

Comments
 (0)