From 3e6a6dbdc00c2153bf3f256ce1c87466b88ec921 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 08:10:15 +0300 Subject: Autocommit at 02.05.2022 @ 08:10 --- src/List/List.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/List/List.cpp') diff --git a/src/List/List.cpp b/src/List/List.cpp index bdb9b4a..a0d0849 100644 --- a/src/List/List.cpp +++ b/src/List/List.cpp @@ -61,6 +61,24 @@ const T& List::operator[](unsigned index) const { return elements[index]; } +template +std::istream& List::read(std::istream& istr) { + istr.read((char*)&length, sizeof(length)); + istr.read((char*)&count, sizeof(count)); + delete[] elements; + elements = new T[length]; + + for (int i = 0; i < count; i++) + istr >> elements[i]; + + return istr; +} + +template +std::ostream& List::write(std::ostream& ostr) const { + return ostr; +} + template unsigned List::get_length() const { return length; -- cgit v1.3.1-23-gd82d