26 typedef _Scalar Scalar;
27 typedef _StorageIndex StorageIndex;
31 typedef typename NumTraits<Scalar>::Real
RealScalar;
36 : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
40 : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
46 : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
56 internal::smart_copy(other.m_values, other.m_values + m_size, m_values);
57 internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices);
67 std::swap(m_allocatedSize, other.m_allocatedSize);
76 void reserve(Index size)
85 if (m_allocatedSize>m_size)
91 if (m_allocatedSize<size)
95 internal::throw_std_bad_alloc();
101 void append(
const Scalar& v, Index i)
106 m_indices[id] = internal::convert_index<StorageIndex>(i);
109 inline Index size()
const {
return m_size; }
110 inline Index allocatedSize()
const {
return m_allocatedSize; }
111 inline void clear() { m_size = 0; }
113 inline Scalar& value(Index i) {
return m_values[i]; }
114 inline const Scalar& value(Index i)
const {
return m_values[i]; }
116 inline StorageIndex& index(Index i) {
return m_indices[i]; }
117 inline const StorageIndex& index(Index i)
const {
return m_indices[i]; }
130 Index
mid = (end+start)>>1;
131 if (m_indices[
mid]<key)
145 else if (key==m_indices[m_size-1])
146 return m_values[m_size-1];
150 return ((
id<m_size) && (m_indices[
id]==key)) ? m_values[id] :
defaultValue;
158 else if (end>start && key==m_indices[end-1])
159 return m_values[end-1];
163 return ((
id<end) && (m_indices[
id]==key)) ? m_values[id] :
defaultValue;
172 if (
id>=m_size || m_indices[
id]!=key)
174 if (m_allocatedSize<m_size+1)
176 m_allocatedSize = 2*(m_size+1);
181 internal::smart_copy(m_values, m_values +
id,
newValues.ptr());
182 internal::smart_copy(m_indices, m_indices+
id,
newIndices.ptr());
187 internal::smart_copy(m_values +
id, m_values +m_size,
newValues.ptr() +
id+1);
188 internal::smart_copy(m_indices+
id, m_indices+m_size,
newIndices.ptr()+
id+1);
195 internal::smart_memmove(m_values +
id, m_values +m_size, m_values +
id+1);
196 internal::smart_memmove(m_indices+
id, m_indices+m_size, m_indices+
id+1);
199 m_indices[id] = internal::convert_index<StorageIndex>(key);
209 for (Index i=0; i<n; ++i)
211 if (!internal::isMuchSmallerThan(value(i), reference, epsilon))
223 inline void reallocate(Index size)
225 #ifdef EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN
226 EIGEN_SPARSE_COMPRESSED_STORAGE_REALLOCATE_PLUGIN
228 eigen_internal_assert(size!=m_allocatedSize);
229 internal::scoped_array<Scalar> newValues(size);
230 internal::scoped_array<StorageIndex> newIndices(size);
231 Index copySize = (std::min)(size, m_size);
233 internal::smart_copy(m_values, m_values+copySize, newValues.ptr());
234 internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr());
238 m_allocatedSize = size;
243 StorageIndex* m_indices;
245 Index m_allocatedSize;
Scalar atInRange(Index start, Index end, Index key, const Scalar &defaultValue=Scalar(0)) const
Like at(), but the search is performed in the range [start,end)
Definition CompressedStorage.h:154
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:24418