Changeset 3918


Ignore:
Timestamp:
Sep 16, 2008, 4:36:48 PM (12 years ago)
Author:
orlov
Message:
  • GExpr isn't resizable anymore.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/opents/samples/trefal.hh

    r3917 r3918  
    6363struct GExpr {
    6464    Term* terms;
    65     size_t terms_size;
    6665    size_t size;
    6766    bool need_delete;
    6867
    69     GExpr () : terms(0), terms_size(0), size(0), need_delete(false) {}
     68    GExpr () : terms(0), size(0), need_delete(false) {}
    7069
    7170    inline GExpr (TExpr& _e);
    7271
    73     GExpr (int size) : terms(new Term[size]), terms_size(size), size(0), need_delete(true) {}
     72    GExpr (int size) : terms(new Term[size]), size(0), need_delete(true) {}
    7473
    7574    GExpr& operator= (GExpr& e) {
     
    8887
    8988    GExpr& add (const Term& t) {
    90         if (size == terms_size) {
    91             Term* new_terms_array = new Term[2*size];
    92             Term* old_terms = terms;
    93             Term* new_terms = new_terms_array;
    94             for (size_t i = 0; i < size; i++)
    95                 *new_terms++ = *old_terms++;
    96             delete[] terms;
    97             terms = new_terms_array;
    98             terms_size = 2*size;
    99         }
    10089        terms[size++] = t;
    10190        return *this;
     
    403392// =================================== GExpr ===================================
    404393
    405 inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), terms_size(0), size(((Expr&)_e).get_len()), need_delete(false) {}
     394inline GExpr::GExpr (TExpr& _e) : terms((Expr&)_e), size(((Expr&)_e).get_len()), need_delete(false) {}
    406395
    407396GExpr& GExpr::add (GExpr& e) {
Note: See TracChangeset for help on using the changeset viewer.