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.0 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. *
  9. *
  10. */
  11. #if defined( Uses_TNSCollection ) && !defined( __TNSCollection )
  12. #define __TNSCollection
  13. // Avoid replacing free by MSS's macro
  14. #include <tv/no_mss.h>
  15. class TNSCollection : public TObject
  16. {
  17. public:
  18. TNSCollection( ccIndex aLimit, ccIndex aDelta );
  19. ~TNSCollection();
  20. virtual void shutDown();
  21. void *at( ccIndex index )
  22. {
  23. if( index < 0 || index >= count )
  24. error(1,0);
  25. return items[index];
  26. }
  27. virtual ccIndex indexOf( void *item );
  28. void atFree( ccIndex index );
  29. void atRemove( ccIndex index );
  30. void remove( void *item );
  31. void removeAll();
  32. void free( void *item );
  33. void freeAll();
  34. virtual void atInsert( ccIndex index, void *item );
  35. void atPut( ccIndex index, void *item );
  36. void atReplace( ccIndex index, void *item ); // SET: Why not? ;-)
  37. virtual ccIndex insert( void *item );
  38. virtual void error( ccIndex code, ccIndex info );
  39. void *firstThat( ccTestFunc Test, void *arg );
  40. void *lastThat( ccTestFunc Test, void *arg );
  41. void forEach( ccAppFunc action, void *arg );
  42. void pack();
  43. virtual void setLimit( ccIndex aLimit );
  44. ccIndex getCount()
  45. { return count; }
  46. // SET: I added it to create collections with static strings inserted
  47. // in it. I think that's a common case and strduping each insertion is
  48. // a real waste.
  49. void setOwnerShip(Boolean option) { shouldDelete=option; }
  50. // SET: That's quite natural. I did it slower than at() but also smaller
  51. // I added it after error became virtual which makes it really bloated.
  52. void *operator[](ccIndex i);
  53. protected:
  54. TNSCollection();
  55. void **items;
  56. ccIndex count;
  57. ccIndex limit;
  58. ccIndex delta;
  59. Boolean shouldDelete;
  60. private:
  61. virtual void freeItem( void *item );
  62. };
  63. #include <tv/yes_mss.h>
  64. #endif // Uses_TNSCollection