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.

89 lines
2.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: DOCLIST.CXX
  7. //
  8. // Contents: Work ID, Property ID list
  9. //
  10. // Classes: CDocItem, CDocList
  11. //
  12. // History: 11-Nov-91 BartoszM Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <pch.cxx>
  16. #pragma hdrstop
  17. #include <doclist.hxx>
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CDocList::WidMax, public
  21. //
  22. // Synopsis: Returns the maximum WORKID of the document list
  23. //
  24. // History: 07-May-93 AmyA Created.
  25. //
  26. // Notes: Checks to make sure the array is sorted if CIDBG==1.
  27. //
  28. //----------------------------------------------------------------------------
  29. WORKID CDocList::WidMax() const
  30. {
  31. Win4Assert( _count > 0 );
  32. #if CIDBG == 1 // check to make sure array is sorted
  33. for( unsigned i=0; i<_count; i++ )
  34. {
  35. if ( i < _count - 1 )
  36. ciAssert( _array[i].wid < _array[i+1].wid );
  37. ciAssert( _array[i].wid > 0 && _array[i].wid < widInvalid );
  38. }
  39. #endif // CIDBG == 1
  40. return _array[_count-1].wid;
  41. }
  42. //+---------------------------------------------------------------------------
  43. //
  44. // Function: CDocList::LokSortOnWid, public
  45. //
  46. // Synopsis: Sorts the WorkId with an insertion sort
  47. //
  48. // History: 23-Mar-93 AmyA Borrowed from sort.cxx
  49. //
  50. //---------------------------------------------------------------------------
  51. void CDocList::LokSortOnWid()
  52. {
  53. if(_count <= 1) // nothing to sort
  54. return;
  55. // loop from through all elements
  56. for(unsigned j = 1; j < _count; j++)
  57. {
  58. CDocItem entry = _array[j];
  59. // go backwards from j-1 shifting up keys greater than 'key'
  60. for ( int i = j - 1; i >= 0 && _array[i].wid > entry.wid; i-- )
  61. {
  62. _array[i+1] = _array[i];
  63. }
  64. // found key less than or equal 'key' or hit the beginning (i == -1)
  65. // insert key in the hole
  66. _array[i+1] = entry;
  67. }
  68. #if CIDBG==1
  69. //
  70. // Assert that there are no duplicate wids in the buffer.
  71. //
  72. for ( unsigned iSrc = 1; iSrc < _count; iSrc++ )
  73. {
  74. Win4Assert( _array[iSrc-1].wid != _array[iSrc].wid );
  75. }
  76. #endif // CIDBG==1
  77. }