Opened 15 years ago
Closed 15 years ago
#302 closed enhancement (fixed)
add insertChild method in SequenceNodeIF
| Reported by: | Stephen Siegel | Owned by: | zirkel |
|---|---|---|---|
| Priority: | major | Milestone: | 1.1 |
| Component: | ast | Version: | 1.1 |
| Keywords: | sequence node insert | Cc: |
Description
I would find it very convenient to add a method to SequenceNodeIF
void insertChild(int position, T child);
which inserts a child node at position, shifting the node that was at position to position+1, etc.
Change History (2)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.

In case it helps (probably not), here is how I was trying to do it:
private void insertNode(int position, SequenceNodeIF<GlobalScopeNodeIF> sequence, GlobalScopeNodeIF newNode) { int numChildren = sequence.numChildren(); GlobalScopeNodeIF previous = newNode; while (position < numChildren) { GlobalScopeNodeIF current = (GlobalScopeNodeIF) sequence.child(position); sequence.setChild(position, previous); previous = current; position++; } sequence.setChild(position, previous); }