void madara::knowledge::containers::FlexMap::exchange( FlexMap& other, bool refresh_keys, bool delete_keys) { if (context_ && other.context_) { std::lock(*context_, *other.context_, mutex_, other.mutex_); ContextGuard context_guard(*context_, std::adopt_lock); ContextGuard other_context_guard(*other.context_, std::adopt_lock); MADARA_GUARD_TYPE guard(mutex_, std::adopt_lock), guard2(other.mutex_, std::adopt_lock); // use the Map container, which already has exchange implemented KnowledgeBase knowledge; knowledge.facade_for(*context_); Map this_map(name_, knowledge, settings_, delimiter_); Map other_map(other.name_, knowledge, other.settings_, delimiter_); this_map.exchange(other_map, refresh_keys, delete_keys); } }
FnMap & FnMap::operator *= (const FnMap &phi) { // composes phi * this FnMap this_map(*this); // make a copy of this morphism FnMap phi_copy(phi); // make a copy of phi incase phi = this // check that morphisms can be composed if (image_rank != phi_copy.domainRank()) { fail(); return *this; } // set new image rank image_rank = phi_copy.imageRank(); int i; FnWord this_image,phi_image; MapIterator x(this_map); while (x.hasNext()) { x.next(); this_image = x.value(); if (this_image == Id) { phi_image = Id; } else { phi_image = FnWord(QString("")); // reset phi_image for (i = 0; i < this_image.length(); i++) { phi_image += phi_copy.value(this_image.at(i)); } phi_image.tighten(); } insert(x.key(),phi_image); } return *this; }