Changeset 1120


Ignore:
Timestamp:
Aug 7, 2003, 10:47:14 PM (17 years ago)
Author:
sveta
Message:
  • Method = is added.
Location:
to-imperative/trunk/runtime
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/runtime/rf_vector.hh

    r1098 r1120  
    3030
    3131  inline bool operator == (Object const& _obj) const ;
    32 
    33   inline void vector_to_exp (Expr& _exp);
    34   inline void vector_init (size_t _length, Expr const& _fill);
    35   inline void vector_fill (Expr const& _fill);
    36   inline void vector_replace (size_t _length, Expr const& exp);
    37   inline void subvector_fill (size_t _index, size_t _length, Expr const& _fill);
     32  inline const Vector& operator = (Vector const&);
    3833};
    3934
  • to-imperative/trunk/runtime/rf_vector.ih

    r1098 r1120  
    1010namespace rftype
    1111{
     12
     13/*inline Vector::Vector(Vector const& _vector)
     14{
     15  new(this) Vector(_vector.length); 
     16  for (size_t i = 0; i < _vector.length; i++)
     17    self[i] = _vector[i];
     18}*/
    1219
    1320inline Vector::Vector (size_t _length /* = 0 */) :
     
    3946      if (!v)
    4047        FATAL ("Invalid argument");
    41       for (size_t i = 0; i < (v->get_length()); i++)
    42         self[index++] = (*v)[i];
    4348    }
    4449  }
     
    5257    self[i] = _vector[_index + i];
    5358}
    54 
    5559
    5660inline unsigned Vector::get_type () const
     
    8286}
    8387
    84 inline void Vector::vector_to_exp (Expr& _exp)
     88inline const Vector& Vector::operator= (Vector const& _vector)
    8589{
    86   for (size_t i = 0; i < get_length(); i++)
    87     _exp = _exp + self[i];
     90  if (this != &_vector) {
     91    this->~Vector();
     92    new (this) Vector(_vector.get_length());
     93    for (size_t i = 0; i < _vector.get_length(); i++)
     94      self[i] = _vector[i];
     95  }
     96  return self;
    8897}
    89 
    90 inline void Vector::vector_init (size_t _length, Expr const& _fill)
    91 {
    92   size_t n = get_length();
    93   if (n < _length) 
    94       expand (_length - n);
    95   else
    96     if (n > _length)
    97       decrease(n - _length);
    98    n = _length;
    99    for (  ; n  ; n--)
    100      self[n-1] = _fill();
    101 }
    102 
    103 inline void Vector::vector_replace (size_t _length, Expr const& _exp)
    104 {
    105   size_t n = get_length();
    106   if (n < _length)
    107     expand (_length - n);
    108   else
    109     if (n > _length)
    110       decrease(n - _length);
    111   Term* p = _exp.get_first();
    112   Term* q = _exp.get_last();
    113   n = 0;
    114   for ( ; p < q ; p++)
    115       self[n++] = (Expr(p))();
    116 }   
    117  
    118 inline void Vector::vector_fill (Expr const& _fill)
    119 {
    120   for (size_t i = 0; i < get_length(); i++)
    121     self[i] = _fill();
    122 }
    123 
    124 inline void Vector::subvector_fill (size_t _index, size_t _length, Expr const& _fill)
    125 {
    126   for (size_t i = 0; i < _length; i++)
    127     self[_index + i] = _fill();
    128 }
     98   
    12999
    130100}
Note: See TracChangeset for help on using the changeset viewer.