List.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include "Circle.h"
  3. #include "Node.h"
  4. class List
  5. {
  6. Node Head; // ôèêòèâíûé ýëåìåíò, êîòîðûé ÿâëÿåòñÿ ïðèçíàêîì íà÷àëà ñïèñêà
  7. Node Tail; // ôèêòèâíûé ýëåìåíò, êîòîðûé ÿâëÿåòñÿ ïðèçíàêîì êîíöà ñïèñêà
  8. size_t m_size; //êîëè÷åñòâî ýëåìåíòîâ
  9. public:
  10. enum class TO { to_head, to_tail };
  11. List();
  12. List(const List&);
  13. List(List&&);
  14. ~List();
  15. void Ad_to(TO, const Circle&);//1) ìåòîä, êîòîðûé äîáàâëÿåò ýëåìåíò â íà÷àëî èëè â êîíåö ñïèñêà
  16. bool RemoveOne(const Circle&);//3) óäàëåíèå èç ñïèñêà ïåðâîãî ýëåìåíòà,
  17. //äàííîå êîòîðîãî ñîâïàäàåò ñî çíà÷åíèåì ïàðàìåòðà.
  18. //Åñëè ýëåìåíò íàéäåí è óäàëåí, ìåòîä âîçâðàùàåò true,
  19. //åñëè ýëåìåíòà ñ òàêèì çíà÷åíèåì â ñïèñêå íå áûëî – false
  20. int Remove_all_match(const Circle&);//4) óäàëåíèå èç ñïèñêà âñåõ ýëåìåíòîâ, äàííîå êîòîðûõ ñîâïàäàåò ñî çíà÷åíèåì ïàðàìåòðà.
  21. // Ìåòîä âîçâðàùàåò êîëè÷åñòâî óäàëåííûõ ýëåìåíòîâ.
  22. void Remove_list();//5) Ñäåëàòü ñïèñîê ïóñòûì
  23. void Swap(Node* prev, Node* movable);
  24. void Sort_list(); //ñîðòèðîâêa ïî âîçðàñòàíèþ ïëîùàäè îáúåêòà.
  25. List& operator=(const List&);
  26. List& operator=(List&&);
  27. /*void InputFromFile();*/
  28. friend std::ostream& operator<<(std::ostream& os, const Node& node);
  29. friend std::ostream& operator<<(std::ostream& os, const List& list);
  30. friend List& operator>>(std::ifstream& is, List& list);
  31. };
  32. std::ostream& operator<<(std::ostream& os, const List& list);
  33. List& operator>>(std::ifstream& is, List& list);