Пример #1
0
Spec init(){
    Spec s;

    s.size = SIZE;
    s.len = LENGTH;
    s.arr = new int(s.size);
    s.shuffle = &shuffle;

    s.shuffle(s);

    return s;
}
Пример #2
0
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);
}
Пример #3
0
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;
}
Пример #4
0
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;
}
Пример #5
0
    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;
    }
Пример #6
0
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;
}
Пример #7
0
  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;
  }
Пример #8
0
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);
}
Пример #9
0
  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);
    });

  }
Пример #10
0
 ZddLookahead(S const& s)
         : spec(s), work(spec.datasize()) {
 }
Пример #11
0
 void destruct(void* p) {
     spec.destruct(p);
 }
Пример #12
0
 int get_root(void* p) {
     return lookahead(p, spec.get_root(p));
 }
Пример #13
0
 int datasize() const {
     return spec.datasize();
 }
Пример #14
0
 int get_child(void* p, int level, int b) {
     return lookahead(p, spec.get_child(p, level, b));
 }
Пример #15
0
 void get_copy(void* to, void const* from) {
     spec.get_copy(to, from);
 }
Пример #16
0
inline size_t Descriptor::get_column_index(StringData name) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_index(name);
}
Пример #17
0
inline DataType Descriptor::get_column_type(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_public_column_type(ndx);
}
Пример #18
0
inline size_t Descriptor::get_column_count() const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_public_column_count();
}
Пример #19
0
inline StringData Descriptor::get_column_name(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_name(ndx);
}
Пример #20
0
 void destructLevel(int level) {
     spec.destructLevel(level);
 }
Пример #21
0
inline bool Descriptor::is_nullable(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_attr(ndx) & col_attr_Nullable;
}
Пример #22
0
 size_t hash_code(void const* p) const {
     return spec.hash_code(p);
 }
Пример #23
0
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);
}
Пример #24
0
 bool equal_to(void const* p, void const* q) const {
     return spec.equal_to(p, q);
 }