From a75ea75a26652750ce1502fe5e784f59132e4fec Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Sun, 19 Jan 2020 11:10:44 +0100
Subject: [PATCH] unit build in algo string properties

---
 .../src/string/properties/StartsWith.cpp      | 15 +++++++
 alib2algo/src/string/properties/StartsWith.h  | 42 +++++++++++++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 alib2algo/src/string/properties/StartsWith.cpp
 create mode 100644 alib2algo/src/string/properties/StartsWith.h

diff --git a/alib2algo/src/string/properties/StartsWith.cpp b/alib2algo/src/string/properties/StartsWith.cpp
new file mode 100644
index 0000000000..efc98afb04
--- /dev/null
+++ b/alib2algo/src/string/properties/StartsWith.cpp
@@ -0,0 +1,15 @@
+/*
+ * StartsWith.cpp
+ *
+ *  Created on: 5. 11. 2014
+ *      Author: Jan Travnicek
+ */
+
+#include "StartsWith.h"
+#include <registration/AlgoRegistration.hpp>
+
+namespace {
+
+auto StartsWithLinearString = registration::AbstractRegister < string::properties::StartsWith, bool, const string::LinearString < > &, const string::LinearString < > & > ( string::properties::StartsWith::startsWith );
+
+} /* namespace */
diff --git a/alib2algo/src/string/properties/StartsWith.h b/alib2algo/src/string/properties/StartsWith.h
new file mode 100644
index 0000000000..8e5bd31fec
--- /dev/null
+++ b/alib2algo/src/string/properties/StartsWith.h
@@ -0,0 +1,42 @@
+/*
+ * StartsWith.h
+ *
+ *  Created on: 5. 11. 2014
+ *      Author: Jan Travnicek
+ */
+
+#ifndef _STRING_STARTS_WITH_H_
+#define _STRING_STARTS_WITH_H_
+
+#include <alib/set>
+#include <alib/map>
+
+#include <string/LinearString.h>
+
+namespace string {
+
+namespace properties {
+
+class StartsWith {
+public:
+	template < class SymbolType >
+	static bool startsWith ( const string::LinearString < SymbolType > & string, const string::LinearString < SymbolType > & prefix );
+
+};
+
+template < class SymbolType >
+bool StartsWith::startsWith ( const string::LinearString < SymbolType > & string, const string::LinearString < SymbolType > & prefix ) {
+	for ( auto prefixIterator = prefix.getContent ( ).begin ( ), stringIterator = string.getContent ( ).begin ( ); prefixIterator != prefix.getContent ( ).end ( ); ++ prefixIterator, ++ stringIterator ) {
+		if ( stringIterator == string.getContent ( ).end ( ) )
+			return false;
+		if ( * prefixIterator != * stringIterator )
+			return false;
+	}
+	return true;
+}
+
+} /* namespace properties */
+
+} /* namespace string */
+
+#endif /* _STRING_STARTS_WITH_H_ */
-- 
GitLab