-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7652f47
commit 5fe63e8
Showing
11 changed files
with
135 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// Created by wangz on 24-8-8. | ||
// | ||
|
||
#include "ClassNode.h" | ||
|
||
namespace Riddle { | ||
} // Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// Created by wangz on 24-8-8. | ||
// | ||
|
||
#ifndef CLASSNODE_H | ||
#define CLASSNODE_H | ||
#include "Class.h" | ||
|
||
namespace Riddle{ | ||
// 防止内存泄漏,启用 RAII 思想 | ||
class ClassNode{ | ||
public: | ||
Class *theClass; | ||
|
||
ClassNode(): theClass(new Class()){ | ||
} | ||
|
||
~ClassNode(){ | ||
} | ||
|
||
Class &get() const{ | ||
return *theClass; | ||
} | ||
}; | ||
} // Riddle | ||
|
||
#endif //CLASSNODE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "doubleMap.h" | ||
|
||
namespace Riddle{ | ||
} // Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef RIDDLE_LANGUAGE_DOUBLEMAP_H | ||
#define RIDDLE_LANGUAGE_DOUBLEMAP_H | ||
#include <ext/pb_ds/tree_policy.hpp> | ||
#include <ext/pb_ds/assoc_container.hpp> | ||
|
||
namespace Riddle{ | ||
template<typename KeyTy, typename Tp> | ||
class doubleMap{ | ||
__gnu_pbds::tree<KeyTy, Tp, std::less<int>, __gnu_pbds::rb_tree_tag, | ||
__gnu_pbds::tree_order_statistics_node_update> tree; | ||
|
||
public: | ||
auto findByKey(KeyTy key){ | ||
return tree.find(key); | ||
} | ||
|
||
auto findByValue(Tp value){ | ||
auto it = tree.lower_bound(value); | ||
if (it->second != value) { | ||
return tree.end(); | ||
} | ||
return it; | ||
} | ||
|
||
void insert(KeyTy key, Tp value){ | ||
tree.insert({key, value}); | ||
} | ||
|
||
auto erase(KeyTy key){ | ||
return tree.erase(key); | ||
} | ||
|
||
bool countByKey(KeyTy key){ | ||
return findByKey(key) != tree.end(); | ||
} | ||
|
||
bool countByValue(Tp value){ | ||
return findByValue(value) != tree.end(); | ||
} | ||
}; | ||
} // Riddle | ||
|
||
#endif //RIDDLE_LANGUAGE_DOUBLEMAP_H |