Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.2 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: rowindex.hxx
  7. //
  8. // Contents: Declaration of the CRowIndex class, used by table windows.
  9. //
  10. // Classes: CRowIndex, CRowCompare
  11. //
  12. // History: 23 Aug 1994 dlee Created
  13. //
  14. //--------------------------------------------------------------------------
  15. #pragma once
  16. #include <tblrowal.hxx> // for CTableRowAlloc
  17. #include <objcur.hxx>
  18. #include <tablecol.hxx>
  19. #include <tblvarnt.hxx>
  20. #include "propdata.hxx"
  21. #include "rowcomp.hxx"
  22. //+-------------------------------------------------------------------------
  23. //
  24. // Class: CRowIndex
  25. //
  26. // Purpose: Maintains row order given a sort object
  27. //
  28. //--------------------------------------------------------------------------
  29. class CRowIndex
  30. {
  31. public:
  32. CRowIndex() : _pRowCompare(0), _aRows( 64 ) { }
  33. ULONG AddRow(TBL_OFF Value);
  34. void AppendRow( TBL_OFF Value )
  35. {
  36. _aRows[ _aRows.Count() ] = Value;
  37. }
  38. void DeleteRow(ULONG iRow);
  39. ULONG ResortRow(ULONG iRow);
  40. void SetComparator(CRowCompare *pRowCompare)
  41. { _pRowCompare = pRowCompare; }
  42. TBL_OFF GetRow(ULONG iRow) const { return _aRows[ iRow ]; }
  43. ULONG RowCount() const { return _aRows.Count(); }
  44. BOOL FindRow( TBL_OFF oTableRow, ULONG &iRowIndex ) const;
  45. void SyncUp( CRowIndex & newIndex );
  46. void ResizeAndInit( ULONG cRowsInNew );
  47. void ClearAll() { _aRows.Clear(); }
  48. LONG FindSplitPoint( TBL_OFF oTableRow ) const;
  49. BOOL FindMidSplitPoint( ULONG & riSplitPoint ) const;
  50. #if CIDBG==1 || DBG==1
  51. void CheckSortOrder() const;
  52. #endif // CIDBG==1 || DBG==1
  53. #ifdef CIEXTMODE
  54. void CiExtDump(void *ciExtSelf);
  55. #endif // CIEXTMODE
  56. private:
  57. ULONG _FindInsertionPoint( TBL_OFF Value ) const;
  58. TBL_OFF * _Base() { return (TBL_OFF *) _aRows.GetPointer(); }
  59. inline BOOL _FindRowByLinearSearch( TBL_OFF oTableRow, ULONG &iRowIndex ) const;
  60. inline BOOL _FindRowByBinarySearch( TBL_OFF oTableRow, ULONG &iRowIndex ) const;
  61. CRowCompare * _pRowCompare;
  62. CDynArrayInPlace<TBL_OFF> _aRows;
  63. };