void insert(size_type i, const T& t) { FFASSERT( i >= 0 && i < (size_type)d_.size() ); d_[i] = fun_(d_[i], t); if (i == 0) return; size_type idx = child_index(i); while (idx < (size_type)d_.size()) { d_[idx] = fun_(d_[idx], t); idx = child_index(idx); } }
//---------------------------------------------------------------------------// void Schema::remove(const std::string &path) { if(m_dtype.id() != DataType::OBJECT_ID) CONDUIT_ERROR("<Schema::remove[OBJECT_ID]> Schema is not OBJECT_ID"); std::string p_curr; std::string p_next; utils::split_path(path,p_curr,p_next); index_t idx = child_index(p_curr); Schema *child = children()[idx]; if(!p_next.empty()) { child->remove(p_next); } else { // any index above the current needs to shift down by one for (index_t i = idx; i < (index_t) object_order().size(); i++) { object_map()[object_order()[i]]--; } object_map().erase(p_curr); object_order().erase(object_order().begin() + idx); children().erase(children().begin() + idx); delete child; } }
//---------------------------------------------------------------------------// const Schema & Schema::fetch_child(const std::string &path) const { // fetch w/ path forces OBJECT_ID if(m_dtype.id() != DataType::OBJECT_ID) CONDUIT_ERROR("<Schema::child[OBJECT_ID]>: Schema is not OBJECT_ID"); std::string p_curr; std::string p_next; utils::split_path(path,p_curr,p_next); // check for parent if(p_curr == "..") { if(m_parent != NULL) // TODO: check for erro (no parent) return m_parent->fetch_child(p_next); } index_t idx = child_index(p_curr); if(p_next.empty()) { return *children()[idx]; } else { return children()[idx]->fetch_child(p_next); } }
child_index invert(face f, child_index idx) { child_index idx_inv = idx; // Invert switch (f) { /////////////////////////////////////////////////////////////////////// // X-axis. case XL: // idx_inv = idx + (+1, 0, 0) case XU: // idx_inv = idx + (-1, 0, 0) { //OCTOPUS_ASSERT(idx.x() == 1); //idx_inv.set_x(0); if (idx.x() == 0) idx_inv.set_x(1); else idx_inv.set_x(0); return idx_inv; } /////////////////////////////////////////////////////////////////////// // Y-axis. case YL: // idx_inv = idx + (0, +1, 0) case YU: // idx_inv = idx + (0, -1, 0) { //OCTOPUS_ASSERT(idx.y() == 1); //idx_inv.set_y(0); if (idx.y() == 0) idx_inv.set_y(1); else idx_inv.set_y(0); return idx_inv; } /////////////////////////////////////////////////////////////////////// // Z-axis. case ZL: // idx_inv = idx + (0, +1, 0) case ZU: // idx_inv = idx + (0, -1, 0) { //OCTOPUS_ASSERT(idx.z() == 1); //idx_inv.set_z(0); if (idx.z() == 0) idx_inv.set_z(1); else idx_inv.set_z(0); return idx_inv; } default: break; } OCTOPUS_ASSERT_MSG(false, "face shouldn't be out-of-bounds"); return child_index(); }
// remove the given Displayable as a child. return success. int Displayable::remove_child(Displayable *d) { // remove first child that matches the pointer, if available. int n = child_index(d); if (n >= 0) { // copy the entries from children+n+1 for (int i=n; i<num_children-1; i++) { children[i] = children[i+1]; } num_children--; _needUpdate = 1; return TRUE; } return FALSE; }
double svg_item_stop::offset () const { double my_offset = get_computed_attribute<svg_attribute_offset> ()->offset (); /// offset must be greater than previous offsets for (int sibling_index = child_index () - 1; sibling_index >= 0; sibling_index--) { const abstract_svg_item *sibling = parent ()->child (sibling_index); if (sibling->type () != svg_item_type::STOP) continue; const svg_item_stop *prev_stop = static_cast<const svg_item_stop *> (sibling); double prev_offset = prev_stop->offset (); my_offset = qMax (my_offset, prev_offset); break; } return my_offset; }
//---------------------------------------------------------------------------// Schema & Schema::fetch(const std::string &path) { // fetch w/ path forces OBJECT_ID init_object(); std::string p_curr; std::string p_next; utils::split_path(path,p_curr,p_next); // handle parent // check for parent if(p_curr == "..") { if(m_parent != NULL) // TODO: check for error (no parent) return m_parent->fetch(p_next); } if (!has_path(p_curr)) { Schema* my_schema = new Schema(); my_schema->m_parent = this; children().push_back(my_schema); object_map()[p_curr] = children().size() - 1; object_order().push_back(p_curr); } index_t idx = child_index(p_curr); if(p_next.empty()) { return *children()[idx]; } else { return children()[idx]->fetch(p_next); } }