From 8e36cb72563737f274bb4e46be32bfce2d82918a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Tr=C3=A1vn=C3=AD=C4=8Dek?= <jan.travnicek@fit.cvut.cz>
Date: Mon, 10 Jan 2022 10:24:54 +0100
Subject: [PATCH] algo: use ext containers

---
 .../src/stringology/compression/LZ77Compression.cpp  |  2 +-
 .../src/stringology/compression/LZ77Compression.h    | 12 ++++++------
 .../stringology/compression/LZ77Decompression.cpp    |  2 +-
 .../src/stringology/compression/LZ77Decompression.h  |  8 ++++----
 .../test-src/stringology/compression/LZ77Test.cpp    | 12 ++++++------
 5 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/alib2algo/src/stringology/compression/LZ77Compression.cpp b/alib2algo/src/stringology/compression/LZ77Compression.cpp
index 46e8c67052..5849ee0743 100644
--- a/alib2algo/src/stringology/compression/LZ77Compression.cpp
+++ b/alib2algo/src/stringology/compression/LZ77Compression.cpp
@@ -3,6 +3,6 @@
 
 namespace {
 
-auto LZ77CompressionLinearString = registration::AbstractRegister < stringology::compression::LZ77Compression, std::vector < std::tuple < unsigned, unsigned, DefaultSymbolType > >, const string::LinearString < > &, unsigned, unsigned > ( stringology::compression::LZ77Compression::compress );
+auto LZ77CompressionLinearString = registration::AbstractRegister < stringology::compression::LZ77Compression, ext::vector < ext::tuple < unsigned, unsigned, DefaultSymbolType > >, const string::LinearString < > &, unsigned, unsigned > ( stringology::compression::LZ77Compression::compress );
 
 } /* namespace */
diff --git a/alib2algo/src/stringology/compression/LZ77Compression.h b/alib2algo/src/stringology/compression/LZ77Compression.h
index 2dedb9286d..387a448324 100644
--- a/alib2algo/src/stringology/compression/LZ77Compression.h
+++ b/alib2algo/src/stringology/compression/LZ77Compression.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#include <tuple>
-#include <vector>
+#include <alib/tuple>
+#include <alib/vector>
 
 #include <string/LinearString.h>
 
@@ -14,7 +14,7 @@ namespace compression {
 class LZ77Compression {
 public:
 	template < class SymbolType >
-	static std::vector < std::tuple < unsigned, unsigned, SymbolType > > compress ( const string::LinearString < SymbolType > & string, unsigned searchBufferSize, unsigned lookaheadBufferSize );
+	static ext::vector < ext::tuple < unsigned, unsigned, SymbolType > > compress ( const string::LinearString < SymbolType > & string, unsigned searchBufferSize, unsigned lookaheadBufferSize );
 
 private:
 	template < class SymbolType >
@@ -23,7 +23,7 @@ private:
 
 // Main method that handle compress
 template < class SymbolType >
-std::vector < std::tuple < unsigned, unsigned, SymbolType > > LZ77Compression::compress ( const string::LinearString < SymbolType > & string, unsigned searchBufferSize, unsigned lookaheadBufferSize ) {
+ext::vector < ext::tuple < unsigned, unsigned, SymbolType > > LZ77Compression::compress ( const string::LinearString < SymbolType > & string, unsigned searchBufferSize, unsigned lookaheadBufferSize ) {
 
 	if(searchBufferSize == 0)
 		throw exception::CommonException("LZ77: search buffer size must be greater than 0");
@@ -33,7 +33,7 @@ std::vector < std::tuple < unsigned, unsigned, SymbolType > > LZ77Compression::c
 
 	size_t pointer = 0;
 
-	std::vector < std::tuple < unsigned, unsigned, SymbolType > > output;
+	ext::vector < ext::tuple < unsigned, unsigned, SymbolType > > output;
 
 	while ( pointer < string.getContent ( ).size ( ) ) {
 		unsigned lookaheadBufferRealSize = lookaheadBufferSize;
@@ -55,7 +55,7 @@ std::vector < std::tuple < unsigned, unsigned, SymbolType > > LZ77Compression::c
 			}
 		}
 
-		output.push_back ( std::tuple < unsigned, unsigned, SymbolType > ( pointer - sbPointer, maxMatch, string.getContent ( ) [ pointer + maxMatch ] ) );
+		output.push_back ( ext::tuple < unsigned, unsigned, SymbolType > ( pointer - sbPointer, maxMatch, string.getContent ( ) [ pointer + maxMatch ] ) );
 		pointer = pointer + maxMatch + 1;
 	}
 
diff --git a/alib2algo/src/stringology/compression/LZ77Decompression.cpp b/alib2algo/src/stringology/compression/LZ77Decompression.cpp
index cadbacae03..4d19b96c57 100644
--- a/alib2algo/src/stringology/compression/LZ77Decompression.cpp
+++ b/alib2algo/src/stringology/compression/LZ77Decompression.cpp
@@ -3,6 +3,6 @@
 
 namespace {
 
-auto LZ77Decompression = registration::AbstractRegister < stringology::compression::LZ77Decompression, string::LinearString < >, const std::vector < std::tuple < unsigned, unsigned, DefaultSymbolType > > & > ( stringology::compression::LZ77Decompression::decompress );
+auto LZ77Decompression = registration::AbstractRegister < stringology::compression::LZ77Decompression, string::LinearString < >, const ext::vector < ext::tuple < unsigned, unsigned, DefaultSymbolType > > & > ( stringology::compression::LZ77Decompression::decompress );
 
 } /* namespace */
diff --git a/alib2algo/src/stringology/compression/LZ77Decompression.h b/alib2algo/src/stringology/compression/LZ77Decompression.h
index c84339ad95..d54534f032 100644
--- a/alib2algo/src/stringology/compression/LZ77Decompression.h
+++ b/alib2algo/src/stringology/compression/LZ77Decompression.h
@@ -1,7 +1,7 @@
 #pragma once
 
-#include <tuple>
-#include <vector>
+#include <alib/tuple>
+#include <alib/vector>
 #include <alib/set>
 
 #include <string/LinearString.h>
@@ -13,12 +13,12 @@ namespace compression {
 class LZ77Decompression {
 public:
 	template < class SymbolType >
-	static string::LinearString < SymbolType > decompress ( const std::vector < std::tuple < unsigned, unsigned, SymbolType > > & input );
+	static string::LinearString < SymbolType > decompress ( const ext::vector < ext::tuple < unsigned, unsigned, SymbolType > > & input );
 };
 
 // Main method that handle decompress
 template < class SymbolType >
-string::LinearString < SymbolType > LZ77Decompression::decompress ( const std::vector < std::tuple < unsigned, unsigned, SymbolType > > & input ) {
+string::LinearString < SymbolType > LZ77Decompression::decompress ( const ext::vector < ext::tuple < unsigned, unsigned, SymbolType > > & input ) {
 
 	string::LinearString < SymbolType > output;
 
diff --git a/alib2algo/test-src/stringology/compression/LZ77Test.cpp b/alib2algo/test-src/stringology/compression/LZ77Test.cpp
index 10fa4b9e43..a9dfe24b99 100644
--- a/alib2algo/test-src/stringology/compression/LZ77Test.cpp
+++ b/alib2algo/test-src/stringology/compression/LZ77Test.cpp
@@ -11,15 +11,15 @@
 TEST_CASE ( "LZ77 Compression", "[unit][algo][stringology][compression]" ) {
 	SECTION ( "Compress and Decompress" ) {
 		auto testcase = GENERATE (
-				std::make_pair ( "aabaacaaaaaababab", std::vector < std::tuple < unsigned, unsigned, char > > { std::make_tuple(0, 0, 'a' ), std::make_tuple(1, 1, 'b' ), std::make_tuple(3, 2, 'c' ), std::make_tuple(3, 2, 'a' ), std::make_tuple(1, 3, 'b' ), std::make_tuple(2, 3, 'b' ) } ),
-				std::make_pair ( "aacaacabcabaaac", std::vector < std::tuple < unsigned, unsigned, char > > { std::make_tuple(0, 0, 'a' ), std::make_tuple(1, 1, 'c' ), std::make_tuple(3, 4, 'b' ), std::make_tuple(3, 3, 'a' ), std::make_tuple(1, 2, 'c' ) } ) );
+				ext::make_pair ( "aabaacaaaaaababab", ext::vector < ext::tuple < unsigned, unsigned, char > > { ext::make_tuple(0, 0, 'a' ), ext::make_tuple(1, 1, 'b' ), ext::make_tuple(3, 2, 'c' ), ext::make_tuple(3, 2, 'a' ), ext::make_tuple(1, 3, 'b' ), ext::make_tuple(2, 3, 'b' ) } ),
+				ext::make_pair ( "aacaacabcabaaac", ext::vector < ext::tuple < unsigned, unsigned, char > > { ext::make_tuple(0, 0, 'a' ), ext::make_tuple(1, 1, 'c' ), ext::make_tuple(3, 4, 'b' ), ext::make_tuple(3, 3, 'a' ), ext::make_tuple(1, 2, 'c' ) } ) );
 
 		string::LinearString < char > string = string::stringFrom ( testcase.first );
-		std::vector < std::tuple < unsigned, unsigned, char > > res = stringology::compression::LZ77Compression::compress ( string, 6, 4 );
-		const std::vector < std::tuple < unsigned, unsigned, char > > & expectedOutput = testcase.second;
+		ext::vector < ext::tuple < unsigned, unsigned, char > > res = stringology::compression::LZ77Compression::compress ( string, 6, 4 );
+		const ext::vector < ext::tuple < unsigned, unsigned, char > > & expectedOutput = testcase.second;
 
 		/* compress */
-		for ( const std::tuple < unsigned, unsigned, char > & resItem : res )
+		for ( const ext::tuple < unsigned, unsigned, char > & resItem : res )
 			INFO ( std::get < 0 > ( resItem ) << " " << std::get < 1 > ( resItem ) << " " << std::get < 2 > ( resItem ) );
 
 		CHECK ( res == expectedOutput );
@@ -33,7 +33,7 @@ TEST_CASE ( "LZ77 Compression", "[unit][algo][stringology][compression]" ) {
 		std::string string = "";
 		string::LinearString < char > input = string::stringFrom ( string );
 
-		std::vector < std::tuple < unsigned, unsigned, char > > out = stringology::compression::LZ77Compression::compress ( input, 6, 4 );
+		ext::vector < ext::tuple < unsigned, unsigned, char > > out = stringology::compression::LZ77Compression::compress ( input, 6, 4 );
 		string::LinearString < char > res = stringology::compression::LZ77Decompression::decompress ( out );
 
 		CHECK ( input == res );
-- 
GitLab