home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iitable.inl < prev    next >
Encoding:
Text File  |  1996-02-22  |  2.2 KB  |  70 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #include <iiexc.h>
  19.  
  20. // ----------
  21. // ITableImpl
  22. // ----------
  23.  
  24. // public members
  25.  
  26. inline INumber&
  27. ITableImpl::
  28. AddMod (INumber& index1, INumber index2) const
  29. { return (index1 = 1 + ((index1 + index2 - 1) % ivAllocatedElements));
  30. }
  31.  
  32. inline IBoolean
  33. ITableImpl::
  34. CanAdd (INumber n) const
  35. { return (ivNumberOfElements + n <= ivAllocatedElements);
  36. }
  37.  
  38. inline INumber&
  39. ITableImpl::
  40. DecMod (INumber& index) const
  41. { IASSERT (index > 0)
  42.   if (--index == 0)
  43.     index = ivAllocatedElements;
  44.   return index;
  45. }
  46.  
  47. inline INumber&
  48. ITableImpl::
  49. IncMod (INumber& index) const
  50. { IASSERT (index <= ivAllocatedElements)
  51.   if (index == ivAllocatedElements)
  52.     index = 0;
  53.   return ++index;
  54. }
  55.  
  56. inline void*
  57. ITableImpl::
  58. NodeAtIndex (INumber index) const
  59. { IASSERT (index > 0 && index <= ivAllocatedElements)
  60.   return (char*)ivNodes + ivNodeSize * (index - 1);
  61. }
  62.  
  63. inline INumber
  64. ITableImpl::
  65. Pos (INumber index) const
  66. { return index >= ivFirst ?
  67.          index - ivFirst + 1:
  68.          ivAllocatedElements - (ivFirst - index) + 1;
  69. }
  70.