Go to the documentation of this file.
52void IntArray :: zero()
58void IntArray :: add(
int value)
60 for (
int &x:
values) x += value;
64void IntArray :: resizeWithValues(
int n,
int allocChunk)
66 if ( allocChunk > 0 && (
int)this->
values.capacity() < n ) {
67 this->
values.reserve(n + allocChunk);
73void IntArray :: resize(
int n)
79void IntArray :: preallocate(
int futureSize)
81 values.reserve(futureSize);
85void IntArray :: enumerate(
int maxValue)
87 this->
values.resize(maxValue);
88 for (
int i = 1; i <= maxValue; ++i ) {
94void IntArray :: followedBy(
const IntArray &b,
int allocChunk)
96 if ( allocChunk && (
int)
values.capacity() < this->giveSize() + b.
giveSize() ) {
103void IntArray :: followedBy(
int b,
int allocChunk)
105 if ( allocChunk && (
int)
values.capacity() < this->giveSize() + 1 ) {
112void IntArray :: erase(
int _pos)
121bool IntArray :: containsOnlyZeroes()
const
133int IntArray :: minimum()
const
144int IntArray :: maximum()
const
155void IntArray :: findNonzeros(
const IntArray &logical)
158 for (
const int &x: logical.
values) {
163 this->
values.resize(newsize);
166 for (
int i = 1; i <= logical.
giveSize(); ++i ) {
167 if ( logical.
at(i) ) {
174void IntArray :: printYourself() const
177 printf(
"IntArray of size : %d\n", this->
giveSize());
178 for (
int i = 1; i <= this->
giveSize(); ++i ) {
180 printf(
" (other components not printed)");
183 printf(
"%d ", this->
at(i) );
191void IntArray :: printYourself(
const std::string name)
const
194 printf(
"%s (%d): ", name.c_str(), this->giveSize());
195 for (
int i = 1; i <= this->
giveSize(); ++i ) {
197 printf(
" (other components not printed)");
200 printf(
"%d ", this->
at(i) );
207bool IntArray :: isAllFinite()
const
209 for (
int val :
values ) {
210 if( !std::isfinite((
double)val) ) {
218void IntArray :: pY()
const {
222void IntArray :: printYourselfToFile(
const std::string filename,
const bool showDimensions)
const
225 std :: ofstream arrayfile (filename);
226 if (arrayfile.is_open()) {
228 arrayfile <<
"IntArray of size : " << this->
giveSize() <<
"\n";
229 for (
int x: *
this ) {
230 arrayfile << x <<
"\t";
241 if ( !stream.
write(this->size()) ) {
246 if ( !stream.
write(
values.data(), this->size()) ) {
280int IntArray :: findFirstIndexOf(
int value)
const
283 auto it = std::find(
values.begin(),
values.end(), value);
285 if ( it ==
values.end() ) {
288 return (
int)(it -
values.begin() + 1);
293int IntArray :: findSorted(
int _val)
const
295 return std::binary_search (
values.begin(),
values.end(), _val);
299void IntArray :: insertSorted(
int val,
int allocChunk)
301 if ( allocChunk > 0 &&
values.size() + 1 >=
values.capacity() ) {
304 auto low = std::lower_bound(
values.begin(),
values.end(), val);
309bool IntArray :: insertSortedOnce(
int val,
int allocChunk)
311 if ( allocChunk > 0 &&
values.size() + 1 >=
values.capacity() ) {
314 auto low = std::lower_bound(
values.begin(),
values.end(), val);
315 if ( low ==
values.end() || *low != val ) {
323void IntArray :: eraseSorted(
int value)
325 auto low = std::lower_bound(
values.begin(),
values.end(), value);
326 if ( *low == value ) {
332int IntArray :: findCommonValuesSorted(
const IntArray &iarray,
IntArray &common,
int allocChunk)
const
336 for (
int val: iarray ) {
339 if (
values [ i ] == val ) {
345 if (
values [ i ] > val ) {
361void IntArray :: insertOnce(
int _p)
369void IntArray :: sort()
371 std::sort(this->
begin(), this->
end());
378 for (
const int &val: x ) {
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int givePackSizeOfSizet(std::size_t count)=0
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
virtual int givePackSizeOfInt(std::size_t count)=0
void checkBounds(std::size_t i) const
std::vector< int >::iterator end()
void followedBy(const IntArray &b, int allocChunk=0)
IntArray(int n=0)
Constructor for sized array. Data is zeroed.
std::vector< int >::iterator begin()
std::vector< int > values
Stored values.
void printYourself() const
Prints receiver on stdout.
int findFirstIndexOf(int value) const
std::ostream & operator<<(std ::ostream &out, const Dictionary &r)
@ CIO_IOERR
General IO error.
This page is part of the
OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak
Bořek Patzák
Project e-mail:
oofem@fsv.cvut.cz
Generated at for OOFEM by
doxygen
1.15.0 written by Dimitri van Heesch,
© 1997-2011