/** * Get an iterator over all AggregateItems that contain the given Tuple. * @param t the input tuple * @return an iterator over all AggregateItems that contain the input Tuple */ public Iterator getAggregates(Tuple t) { int hash = getHashCode(t); IntIterator iit = m_aggregated.getIndex(MEMBER_HASH).rows(hash); HashSet set = new HashSet(); while ( iit.hasNext() ) { int r = iit.nextInt(); set.add(getTuple(m_aggregated.getInt(r, AGGREGATE))); } return set.iterator(); }
/** * Add an item to the aggregation at the given row. * @param row the row index of the aggregate * @param member the item to add to the aggregation */ public void addToAggregate(int row, VisualItem member) { validRowCheck(row, true); if ( !aggregateContains(row, member) ) { int ar = m_aggregated.addRow(); m_aggregated.setInt(ar, AGGREGATE, row); m_aggregated.setInt(ar, MEMBER_HASH, getHashCode(member)); m_aggregated.set(ar, MEMBER, member); fireTableEvent(row, row, EventConstants.ALL_COLUMNS, EventConstants.UPDATE); } }
/** * Get the row index to the aggregate mapping table for the given * aggregate and contained VisualItem. * @param row the table row of the aggregate * @param member the VisualItem to look up * @return the row index into the internal aggregate mapping table for the * mapping between the given aggregate row and given VisualItem */ protected int getAggregatedRow(int row, VisualItem member) { Index index = m_aggregated.index(MEMBER_HASH); int hash = getHashCode(member); int ar = index.get(hash); if ( ar < 0 ) { return -1; } else if ( m_aggregated.getInt(ar, AGGREGATE) == row ) { return ar; } else { for ( IntIterator rows = index.rows(hash); rows.hasNext(); ) { ar = rows.nextInt(); if ( m_aggregated.getInt(ar, AGGREGATE) == row ) return ar; } return -1; } }