Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is all that occurs to me. The linked list is really a seperate detail... so maybe it can be refactored out....</p> <pre><code> public function split(onGroup:CellGroup, directionToMoveSplitCells:String):CellGroup { if (!hasIntersection(onGroup)) return this; valr splitCells:Array; var newGroup:CellGroup ; var numberOfCellsToSplit:int; var splitStartIndex:int; var resultingGroupStartIndex:int; if (directionToMoveSplitCells == "RIGHT") { numberOfCellsToSplit = this.endIndex - onGroup.startIndex + 1; splitStartIndex = this.length - numberOfCellsToSplit; splitCells = trimCells(splitStartIndex, numberOfCellsToSplit); resultingGroupStartIndex = onGroup.endIndex + 1; if (splitCells.length &gt; 0) { newGroup = row.createGroup(splitCells, resultingGroupStartIndex); nextGroup=insertGroup(newGroup,this,nextGroup); } } else { numberOfCellsToSplit = onGroup.endIndex - startIndex + 1; splitStartIndex = 0; splitCells = trimCells(splitStartIndex, numberOfCellsToSplit); resultingGroupStartIndex = onGroup.startIndex - splitCells.length; if (splitCells.length &gt; 0) { newGroup = row.createGroup(splitCells, resultingGroupStartIndex); previousGroup=insertGroup(newGroup,previousGroup,this); var newX:int = (onGroup.endIndex + 1) * cellSize.width; x = newX; } } removeArrayOfCellsFromGroup(splitCells); row.joinGroups(); row.updateGroupIndices(); repositionCellsInGroup(); return newGroup; } private function insertGroup(toInsert:CellGroup,prior:CellGroup,next:CellGroup):CellGroup { toInsert.nextGroup = next; toInsert.previousGroup = prior; if (toInsert.nextGroup ) toInsert.nextGroup.previousGroup = toInsert; if (toInsert.previousGroup ) toInsert.previousGroup.nextGroup = toInsert; return toInsert; } </code></pre> <p>My unindenting of splitCells assigment is to indicate that it is the inoly non-conditional line in the block. I looked at doing what Anon proposed but I can't see any way to make the code actually better that way.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload