com.plumtree.uiinfrastructure.arraywrapper
Class PTGrowableSortedArrayWrapper

java.lang.Object
  extended by com.plumtree.uiinfrastructure.arraywrapper.PTSortedArrayWrapper
      extended by com.plumtree.uiinfrastructure.arraywrapper.PTGrowableSortedArrayWrapper
All Implemented Interfaces:
IPTGrowableSortedArrayWrapperRO

public class PTGrowableSortedArrayWrapper
extends PTSortedArrayWrapper
implements IPTGrowableSortedArrayWrapperRO

MES- The PTGrowableSortedArrayWrapper class is a subclass of PSortedArrayWrapper. It offers some additional functionality- the ability to add and remove rows "dynamically."

Version:
1.0
Author:
MichaelS

Field Summary
protected  int[] m_arrColumnIDs
          MES- We store the mapping of column IDs, because we sometimes have to rebuild m_hashPropIDtoColumn
protected  int m_iPercentIncrease
          MES- m_iPercentIncrease tells us how much we should grow by when we want to grow
protected  XPArrayList m_lstUnusedRowMapping
          MES- m_lstUnusedRowMapping is a list of the empty rows.
protected static int PTGSAW_MINIMUM_PCT_INCREASE
          MES- PTGSAW_MINIMUM_PCT_INCREASE is the minimum percent increase for the array
 
Fields inherited from class com.plumtree.uiinfrastructure.arraywrapper.PTSortedArrayWrapper
m_arrData, m_arrSort, m_bSortOptimized, m_hashPropIDtoColumn, m_lstRowMapping, PTSAW_NEWITEMSINFO_INDEX, PTSAW_NEWITEMSINFO_NEWVALUE, PTSAW_NEWITEMSINFO_PROPERTYID, PTSAW_SORT_ASCENDING, PTSAW_SORT_DESCENDING, PTSAW_SORT_ROW_DIRECTION, PTSAW_SORT_ROW_PROPID
 
Constructor Summary
PTGrowableSortedArrayWrapper()
           
 
Method Summary
 void AddRow(java.lang.Object[] row)
          MES- Clients use the AddRow method to add a row to this array.
protected  void AddRowInternal(java.lang.Object[] row)
          MES- AddRowInternal is an internal helper function that does the heavy lifting when adding a row.
 void AddRows(java.lang.Object[][] rows)
          MES- AddRows is the bulk equivalent of AddRow- it lets clients add multiple rows in a bulk operation.
 void AddRowWithoutSort(java.lang.Object[] row)
          ROB- Clients use the AddRow method to add a row to this array.
protected  int CalculateNextSize(int iNominalSize)
          MES- CalculateNexSize is an internal helper function that figures out, based on the current size, what the next size would be (taking into account m_iPercentIncrease, etc.)
 void ClearArray()
          JF- Clears the entire array of Data.
protected  boolean GrowInternalArrayIfNeeded(int iRowsToAdd)
          MES- GrowInternalArrayIfNeeded is an internal helper function that checks if m_arrData is large enough to hold more rows, and makes it larger if needed.
 void Initialize(int[] arrColumnIDs, java.lang.Object[][] arrData, int[][] arrSort, boolean bRequiresSort)
          MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name
 void Initialize(int[] arrColumnIDs, java.lang.Object[][] arrData, int[][] arrSort, boolean bRequiresSort, int iInitialSize)
          MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name
 void Initialize(int[] arrColumnIDs, java.lang.Object[][] arrData, int[][] arrSort, boolean bRequiresSort, int iInitialSize, int iPercentIncrease)
          MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name
 void RemoveRow(int iRowID)
          MES- RemoveRow lets the client indicate the row number of a row to remove.
 void RemoveRows(int[] iRowIDs)
          MES- RemoveRows is the bulk anologue of RemoveRow
protected  java.lang.Object[][] ResizeArray(java.lang.Object[][] arrData, int iNewRowcount, int iColcount)
          MES- ResizeArray is an internal helper function that changes the number of rows in an array (by creating a new array and copying the data over.)
 void SortArray()
          ROB- Resort the internal array.
 
Methods inherited from class com.plumtree.uiinfrastructure.arraywrapper.PTSortedArrayWrapper
ContainsPropID, GetCount, GetItem, GetSort, MapColumnIDs, SetItem, SetItems, Sort, SortInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.plumtree.uiinfrastructure.arraywrapper.IPTGrowableSortedArrayWrapperRO
GetCount, GetItem, GetSort
 

Field Detail

PTGSAW_MINIMUM_PCT_INCREASE

protected static final int PTGSAW_MINIMUM_PCT_INCREASE
MES- PTGSAW_MINIMUM_PCT_INCREASE is the minimum percent increase for the array

See Also:
Constant Field Values

m_lstUnusedRowMapping

protected XPArrayList m_lstUnusedRowMapping
MES- m_lstUnusedRowMapping is a list of the empty rows. We use this when we want to add a new row to the array- we may be able to sneak the data into an existing row. Every row should either be in m_lstRowMapping or m_lstUnusedRowMapping.


m_arrColumnIDs

protected int[] m_arrColumnIDs
MES- We store the mapping of column IDs, because we sometimes have to rebuild m_hashPropIDtoColumn


m_iPercentIncrease

protected int m_iPercentIncrease
MES- m_iPercentIncrease tells us how much we should grow by when we want to grow

Constructor Detail

PTGrowableSortedArrayWrapper

public PTGrowableSortedArrayWrapper()
Method Detail

AddRowWithoutSort

public void AddRowWithoutSort(java.lang.Object[] row)
ROB- Clients use the AddRow method to add a row to this array. Use SortArray to re-sort after adding multiple entries Added as to fix bug #51045:

Parameters:
row - is the data that the row should hold. The number of entries in row MUST equal the number of columns in m_arrData.

SortArray

public void SortArray()
ROB- Resort the internal array. Use after calling AddRowWithoutSort multiple times. This is an alternative to calling AddRows with a 2d array. Added as to fix bug #51045:


AddRow

public void AddRow(java.lang.Object[] row)
MES- Clients use the AddRow method to add a row to this array. NOTE: This will resort the entire array when adding a row. This can get very expensive. Therefore, this method should not be used for adding large numbers of rows. Use AddRows() instead.

Parameters:
row - is the data that the row should hold. The number of entries in row MUST equal the number of columns in m_arrData.

AddRows

public void AddRows(java.lang.Object[][] rows)
MES- AddRows is the bulk equivalent of AddRow- it lets clients add multiple rows in a bulk operation. NOTE: This method only resorts the array once when adding bulk row. Therefore, this method should be used for adding large numbers of rows instead of calling AddRow() multiple times. AddRow will resort each time, which can get expensive.

Parameters:
rows - is an array of row arrays. The first index is the rownum, the second index is the row data. This is a little confusing, but it makes sense- AddRows takes an array of the items passed to AddRow.

ClearArray

public void ClearArray()
JF- Clears the entire array of Data.


Initialize

public void Initialize(int[] arrColumnIDs,
                       java.lang.Object[][] arrData,
                       int[][] arrSort,
                       boolean bRequiresSort)
MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name

Overrides:
Initialize in class PTSortedArrayWrapper
Parameters:
arrColumnIDs - contains the Property IDs for each column in arrData. The size of arrColumnIDs should be equal to the number of columns in arrData.
arrData - contains the actual data to be stored and manipulated. The index convention matches the Plumtree server- the first index is column, and the second is the row, like arrData[iColIndex][iRowIndex]
arrSort - is a 2D int array of PropertyIDs to sort by. It should contain a column for each sort. The first row holds the PropertyID, and the second row holds the sort direction, PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING
bRequiresSort - indicates if arrData is already sorted as indicated by arrSort. If the client knows that the data is already sorted, we can skip the sort, and we can also optimize access.

Initialize

public void Initialize(int[] arrColumnIDs,
                       java.lang.Object[][] arrData,
                       int[][] arrSort,
                       boolean bRequiresSort,
                       int iInitialSize)
MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name

Parameters:
arrColumnIDs - contains the Property IDs for each column in arrData. The size of arrColumnIDs should be equal to the number of columns in arrData.
arrData - contains the actual data to be stored and manipulated. The index convention matches the Plumtree server- the first index is column, and the second is the row, like arrData[iColIndex][iRowIndex]
arrSort - is a 2D int array of PropertyIDs to sort by. It should contain a column for each sort. The first row holds the PropertyID, and the second row holds the sort direction, PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING
bRequiresSort - indicates if arrData is already sorted as indicated by arrSort. If the client knows that the data is already sorted, we can skip the sort, and we can also optimize access.
iInitialSize - indicates the initial size of the array, if the client wishes to preallocate some rows.

Initialize

public void Initialize(int[] arrColumnIDs,
                       java.lang.Object[][] arrData,
                       int[][] arrSort,
                       boolean bRequiresSort,
                       int iInitialSize,
                       int iPercentIncrease)
MES- Initialize is equivalent to the PTSortedArrayWrapper call of the same name

Parameters:
arrColumnIDs - contains the Property IDs for each column in arrData. The size of arrColumnIDs should be equal to the number of columns in arrData.
arrData - contains the actual data to be stored and manipulated. The index convention matches the Plumtree server- the first index is column, and the second is the row, like arrData[iColIndex][iRowIndex]
arrSort - is a 2D int array of PropertyIDs to sort by. It should contain a column for each sort. The first row holds the PropertyID, and the second row holds the sort direction, PTSAW_SORT_ASCENDING or PTSAW_SORT_DESCENDING
bRequiresSort - indicates if arrData is already sorted as indicated by arrSort. If the client knows that the data is already sorted, we can skip the sort, and we can also optimize access.
iInitialSize - indicates the initial size of the array, if the client wishes to preallocate some rows.
iPercentIncrease - allows the client to indicate the amount by which we should grow the array when we add rows. It's expressed as a percent, e.g. a client would pass in 300 to have the array triple in size when expanding. Values less than 110 are replaced with 110.

RemoveRow

public void RemoveRow(int iRowID)
MES- RemoveRow lets the client indicate the row number of a row to remove.

Parameters:
iRowID - is the row ID of the row to remove. Note that this is the row ID in the SORTED array, we must dereference it to get the "real" row number.

RemoveRows

public void RemoveRows(int[] iRowIDs)
MES- RemoveRows is the bulk anologue of RemoveRow

Parameters:
iRowIDs - is an int array of the row IDs to remove

AddRowInternal

protected void AddRowInternal(java.lang.Object[] row)
MES- AddRowInternal is an internal helper function that does the heavy lifting when adding a row.

Parameters:
row - is the row to add, in the same format as is passed to AddRow.

CalculateNextSize

protected int CalculateNextSize(int iNominalSize)
MES- CalculateNexSize is an internal helper function that figures out, based on the current size, what the next size would be (taking into account m_iPercentIncrease, etc.)

Parameters:
iNominalSize - is the current nominal size- the function calculates the "next" size bigger than this size.
Returns:
the next size larger than iNominalSize

GrowInternalArrayIfNeeded

protected boolean GrowInternalArrayIfNeeded(int iRowsToAdd)
MES- GrowInternalArrayIfNeeded is an internal helper function that checks if m_arrData is large enough to hold more rows, and makes it larger if needed.

Parameters:
iRowsToAdd - is the number of free rows that the client requires.
Returns:
a boolean indicating if we added rows or not. If m_arrData already has room for the requested rows, the return value is false.

ResizeArray

protected java.lang.Object[][] ResizeArray(java.lang.Object[][] arrData,
                                           int iNewRowcount,
                                           int iColcount)
MES- ResizeArray is an internal helper function that changes the number of rows in an array (by creating a new array and copying the data over.)

Parameters:
arrData - is the array we're growing or shrinking
iNewRowcount - is the number of rows desired
Returns:
is the resized array- the array is NOT resized in place.



Copyright © 2002,2003,2004,2005 Plumtree Software, Inc., All Rights Reserved.