/** * Updates the column's inner list elements if the column element already exists or if a new * column was added. * * @param currentColEle * @param elem * @param row * @param col * @param value */ public void updateColumnListElements( RowColumnElement currentColEle, Element elem, int row, int col, Object value) { Element temp = elem; Element currentList = currentColEle.getList(); int elemRowIdx = elem.rowIndex(); while (currentList.getBottom() != null && currentList.getBottom().rowIndex() < elemRowIdx) { currentList = currentList.getBottom(); } if (currentList.getBottom() != null && currentList.getBottom().rowIndex() == elemRowIdx) { currentList.getBottom().value = elem.value; return; } temp.setBottom(currentList.getBottom()); currentList.setBottom(temp); }
/** * Updates the row's inner list elements if the row element already exists or if a new row was * added. * * @param currentRowEle * @param elem * @param row * @param col * @param value */ public void updateRowListElements( RowColumnElement currentRowEle, Element elem, int row, int col, Object value) { Element temp = elem; Element currentList = currentRowEle.getList(); int elemColIdx = elem.columnIndex(); while (currentList.getNext() != null && currentList.getNext().columnIndex() < elemColIdx) { currentList = currentList.getNext(); } if (currentList.getNext() != null && currentList.getNext().columnIndex() == elemColIdx) { currentList.getNext().value = elem.value; return; } temp.setNext(currentList.getNext()); currentList.setNext(temp); }
/** * Returns the object stored at (row,col), if such an element exists, or the default value, if not * such an element exists. Utilizing the column elements, it first locates the correct column's * inner list elements and then traverses through them till it reaches a match with the * corresponding row index. */ @Override public Object elementAt(int row, int col) { RowColumnElement currentColumnEle = columnElementHead.getNext(); Element currentList; while (currentColumnEle != null) { if (currentColumnEle.getIndex() == col) { currentList = currentColumnEle.getList(); while (currentList != null) { if (currentList.rowIndex() == row) { return currentList.value(); } currentList = currentList.getBottom(); } } currentColumnEle = currentColumnEle.getNext(); } return defaultEle; }
private InnerElementIterator(RowColumnElement currentNode, boolean type) { rowIndex = currentNode.index; colIndex = currentNode.index; currentListHead = currentNode.getList(); result = type; }