Merge pull request #86 from alainmarcel/alainmarcel-patch-1
make clean and build.xml updates
diff --git a/src/API/PythonAPI.cpp b/src/API/PythonAPI.cpp
index 5666995..b536da3 100644
--- a/src/API/PythonAPI.cpp
+++ b/src/API/PythonAPI.cpp
@@ -24,7 +24,7 @@
#include "SourceCompile/SymbolTable.h"
#include "Utils/StringUtils.h"
#include "Utils/FileUtils.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/API/SLAPI.cpp b/src/API/SLAPI.cpp
index c6c26c8..fe9735f 100644
--- a/src/API/SLAPI.cpp
+++ b/src/API/SLAPI.cpp
@@ -30,7 +30,7 @@
#include "ErrorReporting/ErrorContainer.h"
#include "Utils/StringUtils.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
diff --git a/src/API/SV3_1aPythonListener.cpp b/src/API/SV3_1aPythonListener.cpp
index 93a23eb..7785a87 100644
--- a/src/API/SV3_1aPythonListener.cpp
+++ b/src/API/SV3_1aPythonListener.cpp
@@ -12,7 +12,7 @@
* Created on April 16, 2017, 8:28 PM
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/Cache/Cache.cpp b/src/Cache/Cache.cpp
index 3eedd54..0b3fb5f 100644
--- a/src/Cache/Cache.cpp
+++ b/src/Cache/Cache.cpp
@@ -29,7 +29,7 @@
#include "SourceCompile/SymbolTable.h"
#include "ErrorReporting/ErrorContainer.h"
#include "Cache/Cache.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "flatbuffers/util.h"
using namespace SURELOG;
diff --git a/src/Cache/PPCache.cpp b/src/Cache/PPCache.cpp
index ae3747f..7bfbfe8 100644
--- a/src/Cache/PPCache.cpp
+++ b/src/Cache/PPCache.cpp
@@ -20,7 +20,7 @@
*
* Created on April 23, 2017, 8:49 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/Cache/ParseCache.cpp b/src/Cache/ParseCache.cpp
index e4580e4..ac51f70 100644
--- a/src/Cache/ParseCache.cpp
+++ b/src/Cache/ParseCache.cpp
@@ -20,7 +20,7 @@
*
* Created on April 29, 2017, 4:20 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/Cache/PythonAPICache.cpp b/src/Cache/PythonAPICache.cpp
index 97da54b..a12148c 100644
--- a/src/Cache/PythonAPICache.cpp
+++ b/src/Cache/PythonAPICache.cpp
@@ -21,7 +21,7 @@
* Created on May 28, 2017, 10:49 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/CommandLine/CommandLineParser.cpp b/src/CommandLine/CommandLineParser.cpp
index 90a4c1e..7ba34ca 100644
--- a/src/CommandLine/CommandLineParser.cpp
+++ b/src/CommandLine/CommandLineParser.cpp
@@ -27,7 +27,7 @@
#include <sstream>
#include <sys/types.h>
#include <sys/stat.h>
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "Utils/StringUtils.h"
#include "Utils/FileUtils.h"
diff --git a/src/CommandLine/CommandLineParser.hpp b/src/CommandLine/CommandLineParser.h
similarity index 100%
rename from src/CommandLine/CommandLineParser.hpp
rename to src/CommandLine/CommandLineParser.h
diff --git a/src/Design/Design.cpp b/src/Design/Design.cpp
index 11226d0..e7f32b5 100644
--- a/src/Design/Design.cpp
+++ b/src/Design/Design.cpp
@@ -30,7 +30,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/ErrorContainer.h"
#include "ErrorReporting/ErrorDefinition.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
diff --git a/src/DesignCompile/Builtin.cpp b/src/DesignCompile/Builtin.cpp
index 1a4698d..af15f1b 100644
--- a/src/DesignCompile/Builtin.cpp
+++ b/src/DesignCompile/Builtin.cpp
@@ -30,7 +30,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompileClass.cpp b/src/DesignCompile/CompileClass.cpp
index 44eaeda..fc96c3e 100644
--- a/src/DesignCompile/CompileClass.cpp
+++ b/src/DesignCompile/CompileClass.cpp
@@ -30,7 +30,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompileDesign.cpp b/src/DesignCompile/CompileDesign.cpp
index e4d4375..bfbf170 100644
--- a/src/DesignCompile/CompileDesign.cpp
+++ b/src/DesignCompile/CompileDesign.cpp
@@ -31,7 +31,7 @@
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/ParseFile.h"
#include "Testbench/ClassDefinition.h"
#include "SourceCompile/Compiler.h"
diff --git a/src/DesignCompile/CompileFileContent.cpp b/src/DesignCompile/CompileFileContent.cpp
index da01f49..4aff41c 100644
--- a/src/DesignCompile/CompileFileContent.cpp
+++ b/src/DesignCompile/CompileFileContent.cpp
@@ -28,7 +28,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompileModule.cpp b/src/DesignCompile/CompileModule.cpp
index 7ca6367..9c6e525 100644
--- a/src/DesignCompile/CompileModule.cpp
+++ b/src/DesignCompile/CompileModule.cpp
@@ -31,7 +31,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompilePackage.cpp b/src/DesignCompile/CompilePackage.cpp
index d34f434..6591337 100644
--- a/src/DesignCompile/CompilePackage.cpp
+++ b/src/DesignCompile/CompilePackage.cpp
@@ -29,7 +29,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompileProgram.cpp b/src/DesignCompile/CompileProgram.cpp
index 0b8752d..1a5a158 100644
--- a/src/DesignCompile/CompileProgram.cpp
+++ b/src/DesignCompile/CompileProgram.cpp
@@ -31,7 +31,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/CompileToolbox.cpp b/src/DesignCompile/CompileToolbox.cpp
index c3cce4e..aea9b6f 100644
--- a/src/DesignCompile/CompileToolbox.cpp
+++ b/src/DesignCompile/CompileToolbox.cpp
@@ -30,7 +30,7 @@
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/Error.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/DesignCompile/DesignElaboration.cpp b/src/DesignCompile/DesignElaboration.cpp
index 718a84d..5862de4 100644
--- a/src/DesignCompile/DesignElaboration.cpp
+++ b/src/DesignCompile/DesignElaboration.cpp
@@ -32,7 +32,7 @@
#include "ErrorReporting/ErrorDefinition.h"
#include "ErrorReporting/ErrorContainer.h"
#include "Config/ConfigSet.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
diff --git a/src/ErrorReporting/ErrorContainer.cpp b/src/ErrorReporting/ErrorContainer.cpp
index 8142193..5d28770 100644
--- a/src/ErrorReporting/ErrorContainer.cpp
+++ b/src/ErrorReporting/ErrorContainer.cpp
@@ -25,7 +25,7 @@
#include <mutex>
#include <iostream>
#include <fstream>
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/Waiver.h"
#include "antlr4-runtime.h"
diff --git a/src/ErrorReporting/Report.cpp b/src/ErrorReporting/Report.cpp
index 0be3806..20ac746 100644
--- a/src/ErrorReporting/Report.cpp
+++ b/src/ErrorReporting/Report.cpp
@@ -23,7 +23,7 @@
#include "SourceCompile/SymbolTable.h"
#include "ErrorReporting/ErrorContainer.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/Report.h"
#include <iostream>
#include <fstream>
diff --git a/src/Library/AntlrLibParserErrorListener.cpp b/src/Library/AntlrLibParserErrorListener.cpp
index 7e143e4..145f1d4 100644
--- a/src/Library/AntlrLibParserErrorListener.cpp
+++ b/src/Library/AntlrLibParserErrorListener.cpp
@@ -26,7 +26,7 @@
using namespace antlr4;
#include "SourceCompile/SymbolTable.h"
#include "Design/FileContent.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "Library/ParseLibraryDef.h"
#include "Library/AntlrLibParserErrorListener.h"
diff --git a/src/Library/ParseLibraryDef.cpp b/src/Library/ParseLibraryDef.cpp
index c6197e4..a4791e0 100644
--- a/src/Library/ParseLibraryDef.cpp
+++ b/src/Library/ParseLibraryDef.cpp
@@ -21,7 +21,7 @@
* Created on January 27, 2018, 5:05 PM
*/
#include "Utils/StringUtils.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
diff --git a/src/Library/SVLibShapeListener.cpp b/src/Library/SVLibShapeListener.cpp
index 2272936..e50cfa7 100644
--- a/src/Library/SVLibShapeListener.cpp
+++ b/src/Library/SVLibShapeListener.cpp
@@ -20,7 +20,7 @@
*
* Created on January 28, 2018, 10:17 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
#include "SourceCompile/CompileSourceFile.h"
diff --git a/src/SourceCompile/AnalyzeFile.cpp b/src/SourceCompile/AnalyzeFile.cpp
index 07c668f..1330d39 100644
--- a/src/SourceCompile/AnalyzeFile.cpp
+++ b/src/SourceCompile/AnalyzeFile.cpp
@@ -23,7 +23,7 @@
#include "SourceCompile/SymbolTable.h"
#include "Design/TimeInfo.h"
#include "Design/DesignElement.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/Error.h"
#include "ErrorReporting/Location.h"
#include "ErrorReporting/ErrorDefinition.h"
diff --git a/src/SourceCompile/AntlrParserErrorListener.cpp b/src/SourceCompile/AntlrParserErrorListener.cpp
index c266f4d..99e0fb3 100644
--- a/src/SourceCompile/AntlrParserErrorListener.cpp
+++ b/src/SourceCompile/AntlrParserErrorListener.cpp
@@ -25,7 +25,7 @@
using namespace std;
using namespace antlr4;
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/SourceCompile/CheckCompile.cpp b/src/SourceCompile/CheckCompile.cpp
index bd088c1..43dd3e7 100644
--- a/src/SourceCompile/CheckCompile.cpp
+++ b/src/SourceCompile/CheckCompile.cpp
@@ -35,7 +35,7 @@
#include "SourceCompile/CompileSourceFile.h"
#include "SourceCompile/Compiler.h"
#include "SourceCompile/ParseFile.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/CheckCompile.h"
using namespace SURELOG;
diff --git a/src/SourceCompile/CompileSourceFile.cpp b/src/SourceCompile/CompileSourceFile.cpp
index f691135..8fb32f1 100644
--- a/src/SourceCompile/CompileSourceFile.cpp
+++ b/src/SourceCompile/CompileSourceFile.cpp
@@ -20,7 +20,7 @@
*
* Created on February 20, 2017, 9:54 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/SourceCompile/Compiler.cpp b/src/SourceCompile/Compiler.cpp
index ab55224..be1a481 100644
--- a/src/SourceCompile/Compiler.cpp
+++ b/src/SourceCompile/Compiler.cpp
@@ -20,7 +20,7 @@
*
* Created on March 4, 2017, 5:16 PM
*/
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/SourceCompile/ParseFile.cpp b/src/SourceCompile/ParseFile.cpp
index 4757186..113c99a 100644
--- a/src/SourceCompile/ParseFile.cpp
+++ b/src/SourceCompile/ParseFile.cpp
@@ -22,7 +22,7 @@
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/SourceCompile/PreprocessFile.cpp b/src/SourceCompile/PreprocessFile.cpp
index ffaa17f..70eba8d 100644
--- a/src/SourceCompile/PreprocessFile.cpp
+++ b/src/SourceCompile/PreprocessFile.cpp
@@ -21,7 +21,7 @@
* Created on February 24, 2017, 9:38 PM
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/SourceCompile/PythonListen.cpp b/src/SourceCompile/PythonListen.cpp
index 7155c57..3669561 100644
--- a/src/SourceCompile/PythonListen.cpp
+++ b/src/SourceCompile/PythonListen.cpp
@@ -22,7 +22,7 @@
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp b/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp
index 872dda9..21cd458 100644
--- a/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp
+++ b/src/SourceCompile/SV3_1aPpTreeShapeListener.cpp
@@ -15,7 +15,7 @@
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
diff --git a/src/SourceCompile/SV3_1aTreeShapeHelper.cpp b/src/SourceCompile/SV3_1aTreeShapeHelper.cpp
index 64c6144..878db4e 100644
--- a/src/SourceCompile/SV3_1aTreeShapeHelper.cpp
+++ b/src/SourceCompile/SV3_1aTreeShapeHelper.cpp
@@ -22,7 +22,7 @@
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/SourceCompile/SV3_1aTreeShapeListener.cpp b/src/SourceCompile/SV3_1aTreeShapeListener.cpp
index 4b4a408..2498959 100644
--- a/src/SourceCompile/SV3_1aTreeShapeListener.cpp
+++ b/src/SourceCompile/SV3_1aTreeShapeListener.cpp
@@ -22,7 +22,7 @@
*/
#include "SourceCompile/SymbolTable.h"
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "ErrorReporting/ErrorContainer.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"
diff --git a/src/Utils/HashMap.h b/src/Utils/HashMap.h
deleted file mode 100644
index cbb2635..0000000
--- a/src/Utils/HashMap.h
+++ /dev/null
@@ -1,361 +0,0 @@
-
-#ifndef HASHMAP_H
-#define HASHMAP_H
-#include <iostream>
-#include <iomanip>
-#include <exception>
-#include <mutex>
-#include <condition_variable>
-
-/*
- * wrapper for items stored in the map
- */
-template <typename K, typename V>
-class HashItem {
- public:
- HashItem(K key, V value) {
- this->key = key;
- this->value = value;
- this->nextItem = nullptr;
- }
-
- /*
- * copy constructor
- */
- HashItem(const HashItem &item) {
- this->key = item.getKey();
- this->value = item.getValue();
- this->nextItem = nullptr;
- }
-
- void setNext(HashItem<K, V> *item) { this->nextItem = item; }
-
- HashItem *getNext() { return nextItem; }
-
- K getKey() { return key; }
-
- V getValue() { return value; }
-
- void setValue(V value) { this->value = value; }
-
- private:
- K key;
- V value;
- HashItem *nextItem;
-};
-
-/*
- * template HashMap for storing items
- * default hash function HF = std::hash<K>
- */
-template <typename K, typename V, typename HF = std::hash<K>>
-class HashMap {
- public:
- /*
- * constructor
- * @mSize specifies the bucket size og the map
- */
- HashMap(std::size_t mSize) {
- // lock initialization for single thread
- std::lock_guard<std::mutex> lock(mtx);
- // if (mSize < 1)
- // throw std::exception("Number of buckets ust be greater than zero.");
-
- mapSize = mSize;
- numOfItems = 0;
- // initialize
- hMap = new HashItem<K, V> *[mapSize]();
- }
-
- /*
- * for simplicity no copy constructor
- * anyway we want test how different threads
- * use same instance of the map
- */
- // HashMap(const HashMap & hmap) = delete;
-
- /*
- * inserts item
- * replaces old value with the new one when item already exists
- * @key key of the item
- * @value value of the item
- */
- void insert(const K &key, const V &value) {
- std::lock_guard<std::mutex> lock(mtx);
- insertHelper(this->hMap, this->mapSize, numOfItems, key, value);
- condVar.notify_all();
- }
-
- /*
- * erases item with key when siúch item exists
- * @key of item to erase
- */
- void erase(const K &key) {
- std::lock_guard<std::mutex> lock(mtx);
- // calculate the bucket where item must be inserted
- std::size_t hVal = hashFunc(key) % mapSize;
- HashItem<K, V> *prev = nullptr;
- HashItem<K, V> *item = hMap[hVal];
-
- while ((item != nullptr) && (item->getKey() != key)) {
- prev = item;
- item = item->getNext();
- }
- // no item found with the given key
- if (item == nullptr) {
- return;
- } else {
- if (prev == nullptr) {
- // item found is the first item in the bucket
- hMap[hVal] = item->getNext();
- } else {
- // item found in one of the entries in the bucket
- prev->setNext(item->getNext());
- }
- delete item;
- numOfItems--;
- }
- condVar.notify_all();
- }
-
- /*
- * get element with the given key by reference
- * @key is the key of item that has to be found
- * @value is the holder where the value of item with key will be copied
- */
- bool getItem(const K &key, V &value) const {
- std::lock_guard<std::mutex> lock(mtx);
- // calculate the bucket where item must be inserted
- std::size_t hVal = hashFunc(key) % mapSize;
- HashItem<K, V> *item = hMap[hVal];
-
- while ((item != nullptr) && (item->getKey() != key)) item = item->getNext();
- // item not found
- if (item == nullptr) {
- return false;
- }
-
- value = item->getValue();
- return true;
- }
-
- /*
- * get element with the given key by reference
- * @key is the key of item that has to be found
- * shows an example of thread waitung for some condition
- * @value is the holder where the value of item with key will be copied
- */
- bool getWithWait(const K &key, V &value) {
- std::unique_lock<std::mutex> ulock(mtxForWait);
- condVar.wait(ulock, [this] { return !this->empty(); });
- // calculate the bucket where item must be inserted
- std::size_t hVal = hashFunc(key) % mapSize;
- HashItem<K, V> *item = hMap[hVal];
-
- while ((item != nullptr) && (item->getKey() != key)) item = item->getNext();
- // item not found
- if (item == nullptr) {
- return false;
- }
-
- value = item->getValue();
- return true;
- }
-
- /*
- * resizes the map
- * creates new map on heap
- * copies the elements into new map
- * @newSize specifies new bucket size
- */
- void resize(std::size_t newSize) {
- std::lock_guard<std::mutex> lock(mtx);
- if (newSize < 1)
- throw std::exception("Number of buckets must be greater than zero.");
-
- resizeHelper(newSize);
- condVar.notify_all();
- }
-
- /*
- * outputs all items of the map
- */
- void outputMap() const {
- std::lock_guard<std::mutex> lock(mtx);
- if (numOfItems == 0) {
- std::cout << "Map is empty." << std::endl << std::endl;
- return;
- }
- std::cout << "Map contains " << numOfItems << " items." << std::endl;
- for (std::size_t i = 0; i < mapSize; i++) {
- HashItem<K, V> *item = hMap[i];
- while (item != nullptr) {
- std::cout << "Bucket: " << std::setw(3) << i
- << ", key: " << std::setw(3) << item->getKey()
- << ", value:" << std::setw(3) << item->getValue()
- << std::endl;
- item = item->getNext();
- }
- }
- std::cout << std::endl;
- }
-
- /*
- * returns true when map has no items
- */
- bool empty() const {
- std::lock_guard<std::mutex> lock(mtx);
- return numOfItems == 0;
- }
-
- void clear() {
- std::lock_guard<std::mutex> lock(mtx);
- deleteMap(hMap, mapSize);
- numOfItems = 0;
- hMap = new HashItem<K, V> *[mapSize]();
- }
-
- void deleteDeep() {
- std::lock_guard<std::mutex> lock(mtx);
- deleteMapDeep(hMap, mapSize);
- numOfItems = 0;
- hMap = new HashItem<K, V> *[mapSize]();
- }
-
- /*
- * returns number of items stored in the map
- */
- std::size_t size() const {
- std::lock_guard<std::mutex> lock(mtx);
- return numOfItems;
- }
-
- /*
- * returns number of buckets
- */
- std::size_t bucket_count() const {
- std::lock_guard<std::mutex> lock(mtx);
- return mapSize;
- }
-
- /*
- * desctructor
- */
- ~HashMap() {
- std::lock_guard<std::mutex> lock(mtx);
- deleteMap(hMap, mapSize);
- }
-
- private:
- std::size_t mapSize;
- std::size_t numOfItems;
- HF hashFunc;
- HashItem<K, V> **hMap;
- mutable std::mutex mtx;
- mutable std::mutex mtxForWait;
- std::condition_variable condVar;
-
- /*
- * help method for inserting key, value item into the map hm
- * mapSize specifies the size of the map, items - the number
- * of stored items, will be incremented when insertion is completed
- * @hm HashMap
- * @mSize specifies number of buckets
- * @items holds the number of items in hm, will be incremented when insertion
- * successful
- * @key - key of item to insert
- * @value - value of item to insert
- */
- void insertHelper(HashItem<K, V> **hm, const std::size_t &mSize,
- std::size_t &items, const K &key, const V &value) {
- std::size_t hVal = hashFunc(key) % mSize;
- HashItem<K, V> *prev = nullptr;
- HashItem<K, V> *item = hm[hVal];
-
- while ((item != nullptr) && (item->getKey() != key)) {
- prev = item;
- item = item->getNext();
- }
-
- // inserting new item
- if (item == nullptr) {
- item = new HashItem<K, V>(key, value);
- items++;
- if (prev == nullptr) {
- // insert new value as first item in the bucket
- hm[hVal] = item;
- } else {
- // append new item on previous in the same bucket
- prev->setNext(item);
- }
- } else {
- // replace existing value
- item->setValue(value);
- }
- }
-
- /*
- * help method to resize the map
- * @newSize specifies new number of buckets
- */
- void resizeHelper(std::size_t newSize) {
- HashItem<K, V> **newMap = new HashItem<K, V> *[newSize]();
- std::size_t items = 0;
- for (std::size_t i = 0; i < mapSize; i++) {
- HashItem<K, V> *item = hMap[i];
- while (item != nullptr) {
- insertHelper(newMap, newSize, items, item->getKey(), item->getValue());
- item = item->getNext();
- }
- }
-
- deleteMap(hMap, mapSize);
- hMap = newMap;
- mapSize = newSize;
- numOfItems = items;
- newMap = nullptr;
- }
-
- /*
- * help function for deleting the map hm
- * @hm HashMap
- * @mSize number of buckets in hm
- */
- void deleteMap(HashItem<K, V> **hm, std::size_t mSize) {
- // delete all nodes
- for (std::size_t i = 0; i < mSize; ++i) {
- HashItem<K, V> *item = hm[i];
- while (item != nullptr) {
- HashItem<K, V> *prev = item;
- item = item->getNext();
- delete prev;
- }
- hm[i] = nullptr;
- }
- // delete the map
- delete[] hm;
- }
-
- /*
- * help function for deleting the map hm
- * @hm HashMap
- * @mSize number of buckets in hm
- */
- void deleteMapDeep(HashItem<K, V> **hm, std::size_t mSize) {
- // delete all nodes
- for (std::size_t i = 0; i < mSize; ++i) {
- HashItem<K, V> *item = hm[i];
- while (item != nullptr) {
- HashItem<K, V> *prev = item;
- item = item->getNext();
- delete prev->getValue();
- delete prev;
- }
- hm[i] = nullptr;
- }
- // delete the map
- delete[] hm;
- }
-};
-
-#endif /* HASHMAP_H */
diff --git a/src/main.cpp b/src/main.cpp
index d9efe97..c4f6f24 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -27,7 +27,7 @@
#include<stdio.h>
#include<sys/types.h>
#include <unistd.h>
-#include "CommandLine/CommandLineParser.hpp"
+#include "CommandLine/CommandLineParser.h"
#include "SourceCompile/SymbolTable.h"
#include "SourceCompile/CompilationUnit.h"
#include "SourceCompile/PreprocessFile.h"