Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /*
  2. * File: Array.h
  3. * Author: rmib
  4. *
  5. * Created on 22 Сентябрь 2011 г., 15:56
  6. */
  7.  
  8. #ifndef ARRAY_H
  9. #define ARRAY_H
  10.  
  11. #include <cstddef>
  12. #include <iostream>
  13.  
  14. const int D = 2;
  15.  
  16. class Object {
  17. public:
  18. typedef int Type;
  19. Object();
  20. virtual ~Object();
  21. friend std::ostream& operator<< (std::ostream&, const Object&);
  22. friend std::istream& operator>> (std::istream&, Object&);
  23. virtual const Object::Type& GetValue() const;
  24. virtual void SetValue(const Object::Type& v);
  25. virtual Object* Copy() const;
  26. protected:
  27. virtual void out( std::ostream& out) const;
  28. virtual void in( std::istream& in);
  29. Object::Type id;
  30. };
  31.  
  32. class PDouble: public Object {
  33. public:
  34. typedef double Type;
  35. PDouble();
  36. virtual const PDouble::Type& GetValue() const;
  37. virtual void SetValue(const PDouble::Type& v);
  38. virtual Object* Copy() const;
  39. protected:
  40. virtual void out( std::ostream& out) const;
  41. virtual void in( std::istream& in);
  42. double value;
  43. };
  44.  
  45. class PInt: public Object {
  46. public:
  47. typedef int Type;
  48. PInt();
  49. virtual const PInt::Type& GetValue() const;
  50. virtual void SetValue(const PInt::Type& v);
  51. virtual Object* Copy() const;
  52. protected:
  53. virtual void out( std::ostream& out) const;
  54. virtual void in( std::istream& in);
  55. int value;
  56. };
  57.  
  58. class Array {
  59. Object **v;
  60. size_t _size;
  61. size_t _maxSize;
  62. void newAlloc(size_t sz);
  63. public:
  64. Array();
  65. Array(const Array& orig);
  66. ~Array();
  67. size_t Size() const;
  68. size_t MaxSize() const;
  69. void Resize(size_t sz, const Object *e);
  70. bool Empty() const;
  71.  
  72. Object *&operator [](size_t n);
  73. const Object *operator [](size_t n) const;
  74.  
  75. Object *&Front();
  76. const Object *Front() const;
  77.  
  78. Object *&Back();
  79. const Object *Back() const;
  80.  
  81. void Assign(size_t n, const Object* e);
  82. void PushBack(const Object* e);
  83. void PopBack();
  84. void Insert(size_t pos, size_t n, const Object* e);
  85. void Erase(size_t ind);
  86. void Clear();
  87. };
  88.  
  89. #endif /* ARRAY_H */
Add Comment
Please, Sign In to add comment