示例#1
0
 PointSet( const self_type& P )
     :
     super(),
     M_npoints( P.nPoints() ),
     M_points( P.points() ),
     M_points_face( P.M_points_face )
 {}
示例#2
0
    void inherit( self_type & parent ) {
#ifdef DEBUGGING
        assert( parent.size() <= size() );
#endif  // DEBUGGING

        memcpy( m_positions, parent.m_positions, parent.size() * sizeof(position_type) );
    }
示例#3
0
    inline void basic_val<T>::copy(self_type const& o)
    {
        if (type() == o.type())
        {
            switch (o.type())
            {
                case type_info::object:
                    o_ = o.o_;
                    break;
                case type_info::array:
                    a_ = o.a_;
                    break;
                case type_info::string:
                    s_ = o.s_;
                    break;
                case type_info::int_:
                    i_ = o.i_;
                    break;
                case type_info::double_:
                    d_ = o.d_;
                    break;
                case type_info::bool_:
                    b_ = o.b_;
                    break;
                default:
                    break;
            }
            return;
        }

        free();

        switch (type_ = o.type())
        {
            case type_info::object:
                new (&o_) object(o.o_);
                break;
            case type_info::array:
                new (&a_) array(o.a_);
                break;
            case type_info::string:
                new (&s_) string(o.s_);
                break;
            case type_info::int_:
                i_ = o.i_;
                break;
            case type_info::double_:
                d_ = o.d_;
                break;
            case type_info::bool_:
                b_ = o.b_;
                break;
            default:
                break;
        }
    }
示例#4
0
void
nsTString_CharT::ReplaceSubstring(const self_type& aTarget,
                                  const self_type& aNewValue)
{
  if (!ReplaceSubstring(aTarget, aNewValue, mozilla::fallible)) {
    // Note that this may wildly underestimate the allocation that failed, as
    // we could have been replacing multiple copies of aTarget.
    AllocFailed(mLength + (aNewValue.Length() - aTarget.Length()));
  }
}
示例#5
0
int32_t
nsACString::RFind(const self_type& aStr, int32_t aOffset,
                  ComparatorFunc aComparator) const
{
  const char_type* begin;
  const char_type* end;
  uint32_t selflen = BeginReading(&begin, &end);

  const char_type* other;
  uint32_t otherlen = aStr.BeginReading(&other);

  if (selflen < otherlen) {
    return -1;
  }

  if (aOffset < 0 || uint32_t(aOffset) > (selflen - otherlen)) {
    end -= otherlen;
  } else {
    end = begin + aOffset;
  }

  for (const char_type* cur = end; cur >= begin; --cur) {
    if (!aComparator(cur, other, otherlen)) {
      return cur - begin;
    }
  }
  return -1;
}
示例#6
0
 self_type cross(self_type const& r) const
 {
     impl_type* pl = (impl_type*)this->data();
     impl_type const* pr = (impl_type const*)r.data();
     impl_type res = pl->cross(*pr);
     return self_type(res(0), res(1), res(2));
 }
示例#7
0
void
nsTSubstring_CharT::Assign(const self_type& aStr)
{
  if (!Assign(aStr, fallible_t())) {
    NS_ABORT_OOM(aStr.Length());
  }
}
int32_t
nsACString::Find(const self_type& aStr, uint32_t aOffset,
                 ComparatorFunc c) const
{
  const char_type *begin, *end;
  uint32_t selflen = BeginReading(&begin, &end);

  if (aOffset > selflen)
    return -1;

  const char_type *other;
  uint32_t otherlen = aStr.BeginReading(&other);

  if (otherlen > selflen - aOffset)
    return -1;

  // We want to stop searching otherlen characters before the end of the string
  end -= otherlen;

  for (const char_type *cur = begin + aOffset; cur <= end; ++cur) {
    if (!c(cur, other, otherlen))
      return cur - begin;
  }
  return -1;
}
示例#9
0
    void push_back( self_type & other, size_t idx ) {
        size_t e = this->m_positions.size();

        this->resize( e + 1 );

        this->setPositionAt( e, other.getPositionAt( idx ) );
    }
示例#10
0
void
nsTSubstring_CharT::Assign(const self_type& aStr)
{
  if (!Assign(aStr, fallible_t())) {
    AllocFailed(aStr.Length());
  }
}
void
nsTString_CharT::ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue )
  {
    if (aTarget.Length() == 0)
      return;

    uint32_t i = 0;
    while (i < mLength)
      {
        int32_t r = FindSubstring(mData + i, mLength - i, aTarget.Data(), aTarget.Length(), false);
        if (r == kNotFound)
          break;

        Replace(i + r, aTarget.Length(), aNewValue);
        i += r + aNewValue.Length();
      }
  }
示例#12
0
bool
nsTSubstring_CharT::Assign( const self_type& str, const fallible_t& )
  {
    // |str| could be sharable.  we need to check its flags to know how to
    // deal with it.

    if (&str == this)
      return true;

    if (!str.mLength)
      {
        Truncate();
        mFlags |= str.mFlags & F_VOIDED;
        return true;
      }

    if (str.mFlags & F_SHARED)
      {
        // nice! we can avoid a string copy :-)

        // |str| should be null-terminated
        NS_ASSERTION(str.mFlags & F_TERMINATED, "shared, but not terminated");

        ::ReleaseData(mData, mFlags);

        mData = str.mData;
        mLength = str.mLength;
        SetDataFlags(F_TERMINATED | F_SHARED);

        // get an owning reference to the mData
        nsStringBuffer::FromData(mData)->AddRef();
        return true;
      }
    else if (str.mFlags & F_LITERAL)
      {
        NS_ABORT_IF_FALSE(str.mFlags & F_TERMINATED, "Unterminated literal");

        AssignLiteral(str.mData, str.mLength);
        return true;
      }

    // else, treat this like an ordinary assignment.
    return Assign(str.Data(), str.Length(), fallible_t());
  }
示例#13
0
 bool equal(const self_type& rhs) const
 {
     if (valid_)
     {
         if (rhs.valid_)
             return this->base() == rhs.base();
         else
             return false;
     }
     else
         return !rhs.valid_;
 }
示例#14
0
PRInt32 
nsACString::RFind(const self_type& aStr, PRInt32 aOffset, ComparatorFunc c) const
{
  const char_type *begin, *end;
  PRUint32 selflen = BeginReading(&begin, &end);

  const char_type *other;
  PRUint32 otherlen = aStr.BeginReading(&other);

  if (selflen < otherlen)
    return -1;

  if (aOffset < 0 || aOffset > (selflen - otherlen))
    end -= otherlen;
  else
    end = begin + aOffset;

  for (const char_type *cur = end; cur >= begin; --cur) {
    if (!c(cur, other, otherlen))
      return cur - begin;
  }
  return -1;
}
示例#15
0
    inline bool basic_val<T>::operator==(self_type const& v) const
    {
        if (type() != v.type())
            return false;

        switch (type())
        {
            case type_info::object:
                return o_ == v.o_;
            case type_info::array:
                return a_ == v.a_;
            case type_info::string:
                return s_ == v.s_;
            case type_info::int_:
                return i_ == v.i_;
            case type_info::double_:
                return d_ == v.d_;
            case type_info::bool_:
                return b_ == v.b_;
            default:
                break;
        }
        return true;
    }
示例#16
0
 friend inline std::size_t hash_value(self_type const& x) {
   std::size_t h = boost::hash<MatchState>()(x.match);
   boost::hash_combine(h, x.input);
   x.hashCombine(h);
   return h;
 }
示例#17
0
 vector_range(self_type const & v, range const & entry_range)
   : base_type(const_cast<handle_type &>(v.handle()),
               entry_range.size(), v.start() + v.stride() * entry_range.start(), v.stride()) {}
示例#18
0
 friend inline void print(O& o, derivation_type const& d, self_type const& s) {
   s.print_projection(o, d);
 }
示例#19
0
inline actor_ptr fwd_aptr(const self_type& s) {
    return s.unchecked();
}
示例#20
0
 bool operator>= (self_type rhs ) const { return internal_id >= rhs.get(); }
示例#21
0
 static inline actor_ptr _(const self_type& s) { return s.get(); }
示例#22
0
 matrix_range(self_type const & A,
              range const & row_range,
              range const & col_range) : base_type(const_cast<handle_type &>(A.handle()),
                                                   row_range.size(), row_range.start() * A.stride1() + A.start1(), A.stride1(), A.internal_size1(),
                                                   col_range.size(), col_range.start() * A.stride2() + A.start2(), A.stride2(), A.internal_size2(),
                                                   A.row_major()) {}
示例#23
0
 bool operator< ( self_type rhs ) const { return internal_id < rhs.get(); }
示例#24
0
 matrix_range(self_type const & other) : base_type(const_cast<handle_type &>(other.handle()),
                                                   other.size1(), other.start1(), other.stride1(), other.internal_size1(),
                                                   other.size2(), other.start2(), other.stride2(), other.internal_size2(),
                                                   other.row_major()) {}
示例#25
0
bool
nsTString_CharT::ReplaceSubstring(const self_type& aTarget,
                                  const self_type& aNewValue,
                                  const fallible_t&)
{
  if (aTarget.Length() == 0)
    return true;

  // Remember all of the non-matching parts.
  AutoTArray<Segment, 16> nonMatching;
  uint32_t i = 0;
  uint32_t newLength = 0;
  while (true)
  {
    int32_t r = FindSubstring(mData + i, mLength - i, static_cast<const char_type*>(aTarget.Data()), aTarget.Length(), false);
    int32_t until = (r == kNotFound) ? mLength - i : r;
    nonMatching.AppendElement(Segment(i, until));
    newLength += until;
    if (r == kNotFound) {
      break;
    }

    newLength += aNewValue.Length();
    i += r + aTarget.Length();
    if (i >= mLength) {
      // Add an auxiliary entry at the end of the list to help as an edge case
      // for the algorithms below.
      nonMatching.AppendElement(Segment(mLength, 0));
      break;
    }
  }

  // If there's only one non-matching segment, then the target string was not
  // found, and there's nothing to do.
  if (nonMatching.Length() == 1) {
    MOZ_ASSERT(nonMatching[0].mBegin == 0 && nonMatching[0].mLength == mLength,
               "We should have the correct non-matching segment.");
    return true;
  }

  // Make sure that we can mutate our buffer.
  // Note that we always allocate at least an mLength sized buffer, because the
  // rest of the algorithm relies on having access to all of the original
  // string.  In other words, we over-allocate in the shrinking case.
  char_type* oldData;
  uint32_t oldFlags;
  if (!MutatePrep(XPCOM_MAX(mLength, newLength), &oldData, &oldFlags))
    return false;
  if (oldData) {
    // Copy all of the old data to the new buffer.
    char_traits::copy(mData, oldData, mLength);
    ::ReleaseData(oldData, oldFlags);
  }

  if (aTarget.Length() >= aNewValue.Length()) {
    // In the shrinking case, start filling the buffer from the beginning.
    const uint32_t delta = (aTarget.Length() - aNewValue.Length());
    for (i = 1; i < nonMatching.Length(); ++i) {
      // When we move the i'th non-matching segment into position, we need to
      // account for the characters deleted by the previous |i| replacements by
      // subtracting |i * delta|.
      const char_type* sourceSegmentPtr = mData + nonMatching[i].mBegin;
      char_type* destinationSegmentPtr = mData + nonMatching[i].mBegin - i * delta;
      // Write the i'th replacement immediately before the new i'th non-matching
      // segment.
      char_traits::copy(destinationSegmentPtr - aNewValue.Length(),
                        aNewValue.Data(), aNewValue.Length());
      char_traits::move(destinationSegmentPtr, sourceSegmentPtr,
                        nonMatching[i].mLength);
    }
  } else {
    // In the growing case, start filling the buffer from the end.
    const uint32_t delta = (aNewValue.Length() - aTarget.Length());
    for (i = nonMatching.Length() - 1; i > 0; --i) {
      // When we move the i'th non-matching segment into position, we need to
      // account for the characters added by the previous |i| replacements by
      // adding |i * delta|.
      const char_type* sourceSegmentPtr = mData + nonMatching[i].mBegin;
      char_type* destinationSegmentPtr = mData + nonMatching[i].mBegin + i * delta;
      char_traits::move(destinationSegmentPtr, sourceSegmentPtr,
                        nonMatching[i].mLength);
      // Write the i'th replacement immediately before the new i'th non-matching
      // segment.
      char_traits::copy(destinationSegmentPtr - aNewValue.Length(),
                        aNewValue.Data(), aNewValue.Length());
    }
  }

  // Adjust the length and make sure the string is null terminated.
  mLength = newLength;
  mData[mLength] = char_type(0);

  return true;
}
示例#26
0
 void assign(const self_type& x)
 {
   std::copy(x.begin(), x.end(), begin());
 }
示例#27
0
 vector_slice(self_type const & v, slice const & entry_slice)
   : base_type(const_cast<handle_type &>(v.handle()),
               entry_slice.size(), v.start() + v.stride() * entry_slice.start(), v.stride() * entry_slice.stride()) {}
示例#28
0
 vector_range(self_type const & other)
   : base_type(const_cast<handle_type &>(other.handle()),
               other.size(), other.start(), other.stride()) {}