Exemplo n.º 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;
}
Exemplo n.º 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);
}
Exemplo n.º 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;
}
Exemplo n.º 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;
}
Exemplo n.º 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;
    }
Exemplo n.º 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;
}
Exemplo n.º 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;
  }
Exemplo n.º 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);
}
Exemplo n.º 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);
    });

  }
Exemplo n.º 10
0
 ZddLookahead(S const& s)
         : spec(s), work(spec.datasize()) {
 }
Exemplo n.º 11
0
 void destruct(void* p) {
     spec.destruct(p);
 }
Exemplo n.º 12
0
 int get_root(void* p) {
     return lookahead(p, spec.get_root(p));
 }
Exemplo n.º 13
0
 int datasize() const {
     return spec.datasize();
 }
Exemplo n.º 14
0
 int get_child(void* p, int level, int b) {
     return lookahead(p, spec.get_child(p, level, b));
 }
Exemplo n.º 15
0
 void get_copy(void* to, void const* from) {
     spec.get_copy(to, from);
 }
Exemplo n.º 16
0
inline size_t Descriptor::get_column_index(StringData name) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_index(name);
}
Exemplo n.º 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);
}
Exemplo n.º 18
0
inline size_t Descriptor::get_column_count() const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_public_column_count();
}
Exemplo n.º 19
0
inline StringData Descriptor::get_column_name(size_t ndx) const noexcept
{
    REALM_ASSERT(is_attached());
    return m_spec->get_column_name(ndx);
}
Exemplo n.º 20
0
 void destructLevel(int level) {
     spec.destructLevel(level);
 }
Exemplo n.º 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;
}
Exemplo n.º 22
0
 size_t hash_code(void const* p) const {
     return spec.hash_code(p);
 }
Exemplo n.º 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);
}
Exemplo n.º 24
0
 bool equal_to(void const* p, void const* q) const {
     return spec.equal_to(p, q);
 }