summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/concept.cpp
diff options
context:
space:
mode:
authorolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-24 10:50:02 -0800
committerolpc user <olpc@xo-5d-f7-86.localdomain>2019-11-24 10:50:02 -0800
commit50be8bb8697b23ff469de142eaebe9666c2a9537 (patch)
tree396d7fbe92312e956de4ec021355c688e2b446b2 /starts/meaning-vm/concept.cpp
parentb3dea01d1ad6803b96865a846b56494506ccc74e (diff)
downloadstandingwithresilience-50be8bb8697b23ff469de142eaebe9666c2a9537.tar.gz
standingwithresilience-50be8bb8697b23ff469de142eaebe9666c2a9537.zip
wip fixing up, decided to refactor: see top of helpers.cpp
Diffstat (limited to 'starts/meaning-vm/concept.cpp')
-rw-r--r--starts/meaning-vm/concept.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/starts/meaning-vm/concept.cpp b/starts/meaning-vm/concept.cpp
index e9fd8e5..993ac62 100644
--- a/starts/meaning-vm/concept.cpp
+++ b/starts/meaning-vm/concept.cpp
@@ -5,14 +5,14 @@ ref concept::id()
return this;
}
-bool concept::linked(ref type)
+bool concept::linked(ref const & type) const
{
return links.count(type.ptr) > 0;
}
-bool concept::linked(ref type, ref target)
+bool concept::linked(ref const & type, ref const & target) const
{
- for (ref t : getAll(type)) {
+ for (ref const & t : getAll(type)) {
if (t == target) {
return true;
}
@@ -20,7 +20,7 @@ bool concept::linked(ref type, ref target)
return false;
}
-ref concept::get(ref type, bool quick)
+ref concept::get(ref const & type, bool quick) const
{
// this is called by name(), so it passes quick=true
auto result = links.equal_range(type.ptr);
@@ -34,7 +34,7 @@ ref concept::get(ref type, bool quick)
return result.first->second;
}
-concept::array concept::getAll(ref type)
+concept::array concept::getAll(ref const & type) const
{
array ret;
for (
@@ -42,17 +42,17 @@ concept::array concept::getAll(ref type)
range.first != range.second;
++ range.first
) {
- ret.push_back(range.first->second);
+ ret.emplace_back(range.first->second);
}
return ret;
}
-void concept::link(ref type, ref target)
+void concept::link(ref const & type, ref const & target)
{
links.insert({type.ptr, target.ptr});
}
-void concept::unlink(ref type, ref target)
+void concept::unlink(ref const & type, ref const & target)
{
auto ls = links.equal_range(type.ptr);
for (auto l = ls.first; l != ls.second; ++ l) {
@@ -64,7 +64,7 @@ void concept::unlink(ref type, ref target)
throw std::out_of_range("no such concept link to erase");
}
-void concept::unlink(ref type)
+void concept::unlink(ref const & type)
{
auto ls = links.equal_range(type.ptr);
if (ls.first == ls.second) {