Spec init(){ Spec s; s.size = SIZE; s.len = LENGTH; s.arr = new int(s.size); s.shuffle = &shuffle; s.shuffle(s); return s; }
std::string Sdf_MarkerUtils<Spec>::GetMarker( const Spec& owner, const SdfPath& connectionPath) { if (connectionPath.IsEmpty()) { return std::string(); } const SdfLayerHandle layer = owner.GetLayer(); const SdfPath specPath = owner.GetPath().AppendTarget(connectionPath); return layer->GetFieldAs<std::string>(specPath, SdfFieldKeys->Marker); }
inline size_t Descriptor::add_column(DataType type, StringData name, DescriptorRef* subdesc, bool nullable) { size_t col_ndx = m_spec->get_public_column_count(); insert_column(col_ndx, type, name, subdesc, nullable); // Throws return col_ndx; }
inline size_t Descriptor::add_column_link(DataType type, StringData name, Table& target, LinkType link_type) { size_t col_ndx = m_spec->get_public_column_count(); insert_column_link(col_ndx, type, name, target, link_type); // Throws return col_ndx; }
int lookahead(void* p, int level) { void* const q = work.data(); while (level >= 1) { for (int b = 1; b < 2; ++b) { spec.get_copy(q, p); if (spec.get_child(q, level, b) != 0) { spec.destruct(q); return level; } spec.destruct(q); } level = spec.get_child(p, level, 0); } return level; }
SdfPathVector Sdf_MarkerUtils<Spec>::GetMarkerPaths(const Spec& owner) { SdfPathVector paths; const SdfLayerHandle layer = owner.GetLayer(); const SdfPathVector children = owner.template GetFieldAs<SdfPathVector>( _MarkerPolicy::GetChildFieldKey()); TF_FOR_ALL(path, children) { const SdfPath targetSpecPath = owner.GetPath().AppendTarget(*path); if (layer->HasField(targetSpecPath, SdfFieldKeys->Marker)) { paths.push_back(*path); } } return paths; }
void create_clusterhead() { Spec spec; Record * representative = make_foobar_record(); spec.it("Creates a ClusterHead", [representative](Description desc)->bool { double cohesion = 0.9953; ClusterHead ch(representative, cohesion); return (cohesion == ch.m_cohesion); }); // Segfaults... //r->print(); // segfaults, which shouldn't be... // Leaks, bad //r->clean_member_attrib_pool(); //std::cout << "sizeof(r): " << sizeof(*r) << std::endl; delete representative; }
void sort(const char* name, void (*sort_f)(Spec&), Spec& s, bool is_print){ if(is_print){ cout << "First " << name << " status: "; display_array(s); } clock_t begin_time = clock(); sort_f(s); cout << "Last " << name << " status(" << float( clock () - begin_time ) / CLOCKS_PER_SEC << ") "; if(is_print) display_array(s); s.shuffle(s); }
void testem_all() { Spec spec; spec.it("Comparing two empty strings scores 0", [this](Description desc)->bool { s1 = ""; s2 = ""; int score = jwcmp(s1, s2); //print_score(s1, s2, score); return (0 == score); }); spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool { s1 = "MATTHEW"; s2 = "XYZ"; int score = jwcmp(s1, s2); sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score); return (0 == score); }); spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool { s1 = "MATTHEW"; s2 = "TALIN"; int score = jwcmp(s1, s2); sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score); return (0 == score); }); spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool { s1 = "MATTHEW"; s2 = "MATHEW"; int score = jwcmp(s1, s2); sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score); return (4 == score); }); spec.it("Comparing %s with %s results in %d", [this, &spec](Description desc)->bool { s1 = "MATTHEW"; s2 = "MATTHEW"; int score = jwcmp(s1, s2); sprintf(spec.buf, desc, s1.c_str(), s2.c_str(), score); return (5 == score); }); }
ZddLookahead(S const& s) : spec(s), work(spec.datasize()) { }
void destruct(void* p) { spec.destruct(p); }
int get_root(void* p) { return lookahead(p, spec.get_root(p)); }
int datasize() const { return spec.datasize(); }
int get_child(void* p, int level, int b) { return lookahead(p, spec.get_child(p, level, b)); }
void get_copy(void* to, void const* from) { spec.get_copy(to, from); }
inline size_t Descriptor::get_column_index(StringData name) const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_column_index(name); }
inline DataType Descriptor::get_column_type(size_t ndx) const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_public_column_type(ndx); }
inline size_t Descriptor::get_column_count() const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_public_column_count(); }
inline StringData Descriptor::get_column_name(size_t ndx) const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_column_name(ndx); }
void destructLevel(int level) { spec.destructLevel(level); }
inline bool Descriptor::is_nullable(size_t ndx) const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_column_attr(ndx) & col_attr_Nullable; }
size_t hash_code(void const* p) const { return spec.hash_code(p); }
inline size_t Descriptor::get_column_link_target(size_t column_ndx) const noexcept { REALM_ASSERT(is_attached()); return m_spec->get_opposite_link_table_ndx(column_ndx); }
bool equal_to(void const* p, void const* q) const { return spec.equal_to(p, q); }