cc_povec.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $XConsortium: cc_povec.h /main/5 1996/08/21 15:49:07 drk $ */
  24. #ifndef _cc_dlist_array_h
  25. #define _cc_dlist_array_h
  26. #include "dti_cc/CC_Dlist.h"
  27. #include "dti_cc/cc_exceptions.h"
  28. template <class T>
  29. class dlist_array : public CC_TPtrDlist<T>
  30. {
  31. protected:
  32. public:
  33. dlist_array(const dlist_array<T>&);
  34. dlist_array(size_t);
  35. virtual ~dlist_array();
  36. //Get these members from CC_TPtrDlist
  37. /*
  38. size_t entries() const ;
  39. void clearAndDestroy();
  40. void prepend(T*);
  41. void append(T*);
  42. T* first() ;
  43. */
  44. T* at(size_t pos) const /* throw boundaryException
  45. * if list size is smaller than pos
  46. */
  47. {
  48. // Hack to get it passed to iter
  49. CC_TPtrSlistIterator<T> iter( *(CC_TPtrSlist<T> *)this );
  50. for ( size_t i = 0; i <=pos; i++ ) {
  51. if ( !(++iter) ) {
  52. throw(CASTCCBEXCEPT ccBoundaryException(0,0,i));
  53. }
  54. }
  55. return( iter.key() );
  56. }
  57. T* operator()(size_t i) const { return at(i); };
  58. T* operator[](size_t i) const { return at(i); };
  59. };
  60. #ifdef EXPAND_TEMPLATES
  61. #include "cc_povec.C"
  62. #endif
  63. #endif