Changeset 1130


Ignore:
Timestamp:
04/16/21 15:55:34 (8 months ago)
Author:
Maciej Komosinski
Message:

Used std::min(), std::max() explicitly to avoid compiler confusion. Used std::size() explicitly instead of the equivalent macro

Location:
cpp
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/2d.h

    r1028 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    66#define _2D_H_
    77
    8 #include "nonstd_stl.h"
    98#include <math.h>
     9#include <algorithm>
    1010
    1111//unification of old GUIXY and Pt2D
     
    5858template<> inline bool XY<int>::operator==(const XY<int> &p) const { return (x == p.x) && (y == p.y); }
    5959
    60 template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>(min(a.x, b.x), min(a.y, b.y)); }
    61 template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>(max(a.x, b.x), max(a.y, b.y)); }
     60template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>(std::min(a.x, b.x), std::min(a.y, b.y)); }
     61template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>(std::max(a.x, b.x), std::max(a.y, b.y)); }
    6262
    6363template <typename T>
     
    7474        T vertical() const { return top + bottom; }
    7575        bool operator==(const XYMargin &other) const { return left == other.left && top == other.top && right == other.right && bottom == other.bottom; }
    76         XYMargin normalized() const { return XYMargin(max(left, T(0)), max(top, T(0)), max(right, T(0)), max(bottom, T(0))); }
     76        XYMargin normalized() const { return XYMargin(std::max(left, T(0)), std::max(top, T(0)), std::max(right, T(0)), std::max(bottom, T(0))); }
    7777};
    7878
     
    162162        }
    163163
    164         XYRect fitAspect(float aspect) ///< place a new rectangle having 'aspect' inside the rectangle
     164        XYRect fitAspect(float aspect) const ///< place a new rectangle having 'aspect' inside the rectangle
    165165        {
    166166                XYRect r;
     
    179179                XY<T> p2 = p + size;
    180180                XY<T> rp2 = r.p + r.size;
    181                 i.p.x = max(p.x, r.p.x);
    182                 i.p.y = max(p.y, r.p.y);
    183                 i.size.x = min(p2.x, rp2.x) - i.p.x;
    184                 i.size.y = min(p2.y, rp2.y) - i.p.y;
     181                i.p.x = std::max(p.x, r.p.x);
     182                i.p.y = std::max(p.y, r.p.y);
     183                i.size.x = std::min(p2.x, rp2.x) - i.p.x;
     184                i.size.y = std::min(p2.y, rp2.y) - i.p.y;
    185185                return i;
    186186        }
  • cpp/common/Convert.cpp

    r1005 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "Convert.h"
    66#include <sstream>
     7#include <algorithm>
    78
    89#if defined __ANDROID__ || defined __BORLANDC__
  • cpp/common/log.cpp

    r875 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    88#include "Convert.h"
    99#include <assert.h>
     10#include <algorithm>
    1011
    1112const char* LOG_LEVEL_ARRAY[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " };
     
    3637{
    3738        assert((level>=LOG_MIN) && (level<=LOG_MAX));
    38         level = min(LOG_MAX, max(LOG_MIN, level));
     39        level = std::min(LOG_MAX, std::max(LOG_MIN, level));
    3940        return LOG_LEVEL_ARRAY[level + 1];
    4041}
  • cpp/common/loggers/loggers.h

    r1100 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    99#include <common/threads.h>
    1010#include <common/nonstd_stl.h>
     11#include <algorithm>
    1112
    1213class LoggerBase;
  • cpp/common/loggers/loggertostdout.cpp

    r875 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "loggertostdout.h"
    66#include <common/console.h>
     7#include <algorithm>
    78#include <assert.h>
    89#ifdef SHP
     
    3839        {
    3940                assert((level>=LOG_MIN) && (level<=LOG_MAX));
    40                 level = min(LOG_MAX, max(LOG_MIN, level));
     41                level = std::min(LOG_MAX, std::max(LOG_MIN, level));
    4142                printf(log_format, log_level[level + 1], obj, method, msg, "\n");
    4243        }
  • cpp/common/nonstd_stl.h

    r1108 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    66#define _NONSTD_STL_H_
    77
    8 //stl jak sama nazwa glosi wcale nie jest nonstd
     8//making STL more standard
    99
    1010#include <string>
    1111using std::string;
    12 #ifndef SHP //bada nie ma wstring
     12#ifndef SHP //STL in the bada OS has no wstring
    1313using std::wstring;
    1414#endif
     
    1717using std::vector;
    1818
    19 #include <algorithm> //std::min,max,swap
    20 using std::min;
    21 using std::max;
    22 using std::swap;
    2319
     20//below: not used since 2020 (these macros are replaced by std::ssize()), may be removed...
    2421
    2522// ------------------- ARRAY_LENGTH -------------------
    2623
    27 //staromodne makro, niezabezpieczone przed uzyciem wskaznika w roli "x"
     24//old-fashioned macro, unprotected against the use of the pointer as "x"
    2825//#define ARRAY_LENGTH(x) (sizeof(x)/sizeof((x)[0]))
    2926
    30 //hakerskie makro ktore wykrywa czesc pomy³kowych przypadkow uzycia
     27//hacker macro that detects some of the misuse cases
    3128//#define ARRAY_LENGTH(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
    3229
    33 //szablonowa funkcja pisana przez sredniozaawansowanych, jak to funkcja - nie daje niestety sta³ej w czasie kompilacji
     30//template function by intermediate-level devs, as a function it unfortunately does not give a constant at compile time
    3431//template<typename T, std::size_t N> inline std::size_t ARRAY_LENGTH( T(&)[N] ) { return N; } //"constexpr" dopiero w C++0x
    3532
    36 //szablony hakerskie: tablica bajtow o dlugosci N - tak dluga jak tablica o któr¹ pytamy...
     33//hacker templates: array of bytes of length N - as long as the array we are asking for...
    3734//template <typename T, std::size_t N>
    3835//char (&array_temp(T (&a)[N]))[N];
     
    4441//char (&array_temp(const T (&a)[N]))[N];
    4542
    46 //...ktor¹ mozna potem uzyc normalnie w sizeof i dzieki temu mamy const w compile-time. tak uzyteczne jak staromodne makro ale z pelna kontrola bledow
     43//...which can then be used in sizeof and thus we have const in compile-time. This is as useful as the old-fashioned macro above, but with full error control
    4744//#define ARRAY_LENGTH(x) sizeof(array_temp(x))
    4845
    4946//final and no longer needed version ;-) (c++17)
    50 #define ARRAY_LENGTH(x) int(std::size(x))
     47//#define ARRAY_LENGTH(x) int(std::size(x))
     48//(still room for improvement because unsigned=risky, ssize() upcoming since C++20)
    5149
    5250
  • cpp/common/util-stl.h

    r1124 r1130  
    66#define _UTIL_STL_H_
    77
    8 #include "nonstd_stl.h"
    98#include <map>
     9#include <algorithm>
    1010
    1111template<typename T, std::size_t N> void push_back(vector<T>& v, T(&d)[N])
  • cpp/common/util-string.cpp

    r1036 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    99#include <assert.h>
    1010#include <cstdlib> //malloc()
     11#include <algorithm>
    1112#ifdef USE_VIRTFILE
    1213#include <common/virtfile/virtfile.h>
  • cpp/frams/_demos/evol_test.cpp

    r1031 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 2019-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 2019-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    195195        for (int i = 0; i < nr_evals; i++)
    196196        {
    197                 int selected_positive = tournament(population, max(2, int(sqrt(population.size()) / 2))); //moderate positive selection pressure
     197                int selected_positive = tournament(population, std::max(2, int(sqrt(population.size()) / 2))); //moderate positive selection pressure
    198198                int selected_negative = rndUint(population.size()); //random negative selection
    199199
     
    214214                else
    215215                {
    216                         int selected_positive2 = tournament(population, max(2, int(sqrt(population.size()) / 2)));
     216                        int selected_positive2 = tournament(population, std::max(2, int(sqrt(population.size()) / 2)));
    217217                        Geno xover = genman.crossOver(population[selected_positive].geno, population[selected_positive2].geno);
    218218                        if (xover.getGenes() == "")
  • cpp/frams/_demos/printconvmap.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    8888        :model(m)
    8989{
    90         joint_offset = max(10, (int(9 + model.getPartCount()) / 10) * 10);
    91         neuron_offset = joint_offset + max(10, (int(9 + model.getJointCount()) / 10) * 10);
    92         max_element = neuron_offset + max(10, (int(9 + model.getNeuroCount()) / 10) * 10);
     90        joint_offset = std::max(10, (int(9 + model.getPartCount()) / 10) * 10);
     91        neuron_offset = joint_offset + std::max(10, (int(9 + model.getJointCount()) / 10) * 10);
     92        max_element = neuron_offset + std::max(10, (int(9 + model.getNeuroCount()) / 10) * 10);
    9393        for (int i = 0; i < model.getPartCount(); i++)
    9494                map.add(Model::partToMap(i), Model::partToMap(i), i, i);
  • cpp/frams/canvas/neurodiagram.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1313#include <frams/simul/simul.h>
    1414#include "common/nonstd_time.h"
     15#include <algorithm>
    1516
    1617#define FIELDSTRUCT NeuroDiagram
     
    231232        NeuroProbe *probe = new NeuroProbe(getNS(i));
    232233        Pixel s = getSize();
    233         s.x = s.y = max(probe->getSize().x, min(s.x / 3, s.y / 3));
     234        s.x = s.y = std::max(probe->getSize().x, std::min(s.x / 3, s.y / 3));
    234235        probes += (void*)probe;
    235236        add(probe);
     
    503504                                int *dr = drawing;
    504505                                int w = size.x - 2, h = size.y - clienttop - clientbottom;
    505                                 int scale = min(w, h);
     506                                int scale = std::min(w, h);
    506507                                int x0 = clienttop + leftborder + ((w > h) ? (w - h) / 2 : 0);
    507508                                int y0 = clientleft + topborder + ((h > w) ? (h - w) / 2 : 0);
  • cpp/frams/canvas/nn_smart_layout.cpp

    r492 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "nn_layout.h"
    66#include <vector>
    7 #include "common/nonstd_stl.h"
     7#include <algorithm>
    88#ifdef __BORLANDC__
    99 #include <alloc.h> //borland needs for alloc/free
     
    131131           */
    132132        int x1, y1, x2, y2; // union rectangle
    133         x1 = max(0, b2->minx - b->minx + dx);
    134         x2 = min(b->maxx - b->minx, -b->minx + dx + b2->maxx);
     133        x1 = std::max(0, b2->minx - b->minx + dx);
     134        x2 = std::min(b->maxx - b->minx, -b->minx + dx + b2->maxx);
    135135        if (x1 > x2) return 1;
    136         y1 = max(0, b2->miny - b->miny + dy);
    137         y2 = min(b->maxy - b->miny, -b->miny + dy + b2->maxy);
     136        y1 = std::max(0, b2->miny - b->miny + dy);
     137        y2 = std::min(b->maxy - b->miny, -b->miny + dy + b2->maxy);
    138138        if (y1 > y2) return 1;
    139139        int x, y;
     
    162162                b->dodajelement(e, einfo[e].x + dx, einfo[e].y + dy);
    163163        }
    164         b->minx = min(b->minx, dx + b2->minx);
    165         b->miny = min(b->miny, dy + b2->miny);
    166         b->maxx = max(b->maxx, dx + b2->maxx);
    167         b->maxy = max(b->maxy, dy + b2->maxy);
     164        b->minx = std::min(b->minx, dx + b2->minx);
     165        b->miny = std::min(b->miny, dy + b2->miny);
     166        b->maxx = std::max(b->maxx, dx + b2->maxx);
     167        b->maxy = std::max(b->maxy, dy + b2->maxy);
    168168
    169169        DB(
  • cpp/frams/genetics/f1/f1_conv.cpp

    r1039 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "f1_conv.h"
    6 #include <common/nonstd_stl.h>
    76#include <common/log.h>
    87#include <frams/util/multirange.h>
     
    1110#include <ctype.h>
    1211#include <assert.h>
     12#include <algorithm>
    1313
    1414//#define v1f1COMPATIBLE //as in ancient Framsticks 1.x
     
    273273int Builder::growJoint(int part1, int part2, Pt3D &angle, GeneProps &c, const char *g)
    274274{
    275         double len = min(2.0, c.length);
     275        double len = std::min(2.0, c.length);
    276276        sprintf(tmp, "p1=%d,p2=%d,dx=%lg,rx=%lg,ry=%lg,rz=%lg,stam=%lg,vr=%g,vg=%g,vb=%g",
    277277                part1, part2, len, angle.x, angle.y, angle.z, c.stamina, c.cred, c.cgreen, c.cblue);
  • cpp/frams/genetics/f9/f9_conv.cpp

    r1108 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    66#include <frams/model/model.h>
    77#include <string.h>
    8 #include <common/nonstd_stl.h> //ARRAY_LENGTH
    98
    109#define APPLY_DETERMINISTIC_BODY_NOISE //this genetic representation easily produces perfectly vertical sticks that would stay upright forever in simulation. In most cases such infinite perfection is not desired, so we make the construct less perfect by perturbing its coordinates.
     
    129128        static int g[] = { 0, 1, 1, 1, 0, 0 };
    130129        static int b[] = { 0, 0, 0, 1, 1, 1 };
    131         int maxind = ARRAY_LENGTH(r) - 1;
     130        int maxind = int(std::size(r)) - 1;
    132131
    133132        int joints_count = m.getJointCount();
  • cpp/frams/genetics/fB/fB_conv.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    77#include <frams/param/paramobj.h>
    88#include <vector>
     9#include <algorithm>
    910#include <frams/util/multimap.h>
    1011#include "fB_general.h"
     
    250251                                double mn, mx, def;
    251252                                par.getMinMaxDouble(propindex, mn, mx, def);
    252                                 par.setDouble(propindex, min(mx, max(mn, (mx - mn) * val + mn)));
     253                                par.setDouble(propindex, std::min(mx, std::max(mn, (mx - mn) * val + mn)));
    253254                        }
    254255                        propindex++;
  • cpp/frams/genetics/fB/fB_oper.cpp

    r999 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include <frams/util/sstring.h>
    66#include <vector>
     7#include <algorithm>
    78#include <frams/param/param.h>
    89#include "fB_conv.h"
     
    461462        {
    462463                // get maximal count of genes from both parents
    463                 int maxgenecount = max(fB_GenoHelpers::geneCountNoNested(parent1),
     464                int maxgenecount = std::max(fB_GenoHelpers::geneCountNoNested(parent1),
    464465                        fB_GenoHelpers::geneCountNoNested(parent2));
    465466
  • cpp/frams/genetics/fF/fF_conv.cpp

    r994 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "fF_conv.h"
    66#include "fF_genotype.h"
    7 #include <common/nonstd_stl.h>
    87#include <common/Convert.h>
    98
  • cpp/frams/genetics/fF/fF_oper.cpp

    r974 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4949        par.load(gene);
    5050        static const int propsToMutate[] = fF_PROPS_TO_MUTATE;
    51         int which = rndUint(ARRAY_LENGTH(propsToMutate));
     51        int which = rndUint(std::size(propsToMutate));
    5252        bool mutated_ok = GenoOperators::mutatePropertyNaive(par.param, propsToMutate[which]);
    5353        if (mutated_ok)
  • cpp/frams/genetics/fS/fS_general.cpp

    r1108 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 2019-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 2019-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1313#include "common/nonstd_math.h"
    1414#include <frams/model/geometry/part_distance_estimator.h>
     15#include <algorithm>
    1516
    1617int fS_Genotype::precision = 4;
  • cpp/frams/genetics/fS/fS_oper.cpp

    r1056 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 2019-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 2019-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    77#include "fS_oper.h"
    88#include "frams/util/rndutil.h"
     9#include <algorithm>
    910
    1011#define FIELDSTRUCT GenoOper_fS
     
    362363                        {
    363364                                // Remove the selected child
    364                                 swap(randomNode->children[selectedIndex], randomNode->children[childCount - 1]);
     365                                std::swap(randomNode->children[selectedIndex], randomNode->children[childCount - 1]);
    365366                                randomNode->children.pop_back();
    366367                                randomNode->children.shrink_to_fit();
     
    586587                        fS_Neuron *it = randomNode->neurons[rndUint(size)];
    587588                        geno.rearrangeNeuronConnections(it, SHIFT::LEFT);        // Important to rearrange the neurons before deleting
    588                         swap(it, randomNode->neurons.back());
     589                        std::swap(it, randomNode->neurons.back());
    589590                        randomNode->neurons.pop_back();
    590591                        randomNode->neurons.shrink_to_fit();
  • cpp/frams/genetics/fn/fn_conv.h

    r779 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    77
    88#include <frams/genetics/genoconv.h>
     9#include <common/nonstd_stl.h>
    910
    1011// The fn->f0 converter
  • cpp/frams/genetics/geneprops.cpp

    r1039 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "geneprops.h"
     6#include <algorithm>
    67
    78GeneProps GeneProps::standard_values;
     
    5455#ifdef v1f1COMPATIBLE
    5556        case 'L': length += (3.0 - length)*0.3;
    56                 length = min(length, Model::getMaxJoint().d.x); break;
     57                length = std::min(length, Model::getMaxJoint().d.x); break;
    5758#else
    5859        case 'L': length += (2.0 - length)*0.3; //2.0 is currently Model::getMaxJoint().d.x so min() does not limit the range
    59                 length = min(length, Model::getMaxJoint().d.x); break;
     60                length = std::min(length, Model::getMaxJoint().d.x); break;
    6061#endif
    6162        case 'l': length += (0.33 - length)*0.3;
    62                 length = max(length, Model::getMinJoint().d.x); break;
     63                length = std::max(length, Model::getMinJoint().d.x); break;
    6364
    6465        case 'W': weight += (2.0 - weight)*0.3;  break;
  • cpp/frams/model/autoname.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "autoname.h"
    6 #include "common/nonstd_stl.h"
     6#include <algorithm>
    77#include <ctype.h>
    88
     
    100100        if (model.getPartCount() > 0)
    101101        {
    102                 cialo = min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1);
     102                cialo = std::min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1);
    103103                poz = 0;
    104104                for (i = 0; i <= cialo; i++) // budowanie "opisu" ciala
     
    106106                        nextpoz = ((model.getPartCount()) * (i + 1)) / (cialo + 1) - 1;
    107107                        w = 1.0;
    108                         for (; poz <= nextpoz; poz++) w = max(w, model.getPart(poz)->mass);
    109                         tmpc[i] = Sp[min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)];
     108                        for (; poz <= nextpoz; poz++) w = std::max(w, model.getPart(poz)->mass);
     109                        tmpc[i] = Sp[std::min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)];
    110110                }
    111111                tmpc[i] = 0;
     
    117117        if (model.getNeuroCount() > 0)
    118118        {
    119                 mozg = min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1);
     119                mozg = std::min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1);
    120120                poz = 0;
    121121                for (i = 0; i <= mozg; i++) // budowanie "opisu" mozgu
     
    123123                        nextpoz = (model.getNeuroCount() * (i + 1)) / (mozg + 1) - 1;
    124124                        wint = 0;
    125                         for (; poz <= nextpoz; poz++) wint = max(wint, model.getNeuro(poz)->getInputCount());
    126                         tmpm[i] = Sam[min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)];
     125                        for (; poz <= nextpoz; poz++) wint = std::max(wint, model.getNeuro(poz)->getInputCount());
     126                        tmpm[i] = Sam[std::min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)];
    127127                }
    128128                tmpm[i] = 0;
  • cpp/frams/model/model.h

    r1118 r1130  
    1313#include <frams/util/advlist.h>
    1414#include <frams/util/usertags.h>
     15#include <common/nonstd_stl.h>
    1516
    1617extern ParamEntry f0_model_paramtab[];
  • cpp/frams/model/similarity/EMD/emd.c

    r1064 r1130  
    1919#include <stdlib.h>
    2020#include <math.h>
     21#include <algorithm>
    2122
    2223#include "emd.h"
     
    100101{
    101102  int itr;
    102   int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
     103  int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
    103104  double totalCost;
    104105  float w;
     
    211212{
    212213  int i, j;
    213   int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
     214  int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
    214215  double sSum, dSum, diff;
    215216  feature_t *P1, *P2;
     
    474475{
    475476    int i, j, k;
    476     int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
     477    int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
    477478    double xMin;
    478479    int steps;
     
    555556{
    556557  int i, steps;
    557   int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
     558  int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
    558559  node2_t **CurX, *NewX;
    559560  char *IsUsed=new char[2*max_n];
     
    652653{
    653654  int i, j, found, minI, minJ;
    654   int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
     655  int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.
    655656  double deltaMin, oldVal, diff;
    656657  double** Delta = new double*[_n1];
  • cpp/frams/model/similarity/measure-distribution.cpp

    r1125 r1130  
    7979        //int size = sampled.getPartCount();
    8080        //if (size < (int) sqrt((double) std::numeric_limits<int>::max())) //prevent exceeding int limits
    81         //      samples_taken = min(samples_num, size*size);
     81        //      samples_taken = std::min(samples_num, size*size);
    8282
    8383        rndgen.seed(55); //For determinism. Otherwise the descriptors (that choose samples pseudo-randomly) for the same Model can yield different values and so the dissimilarity between the object and its copy will not be 0.
  • cpp/frams/neuro/impl/neuroimpl-channels.cpp

    r907 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "neuroimpl-channels.h"
    6 #include <common/nonstd_stl.h>
     6#include <algorithm>
    77
    88void NI_Channelize::go()
     
    1818        if (c < 2) { setState(getWeightedInputState(1)); return; }
    1919        double s = getWeightedInputState(0);
    20         s = (max(-1.0, min(1.0, s)) + 1.0) / 2.0; // 0..1
     20        s = (std::max(-1.0, std::min(1.0, s)) + 1.0) / 2.0; // 0..1
    2121        int i1;
    22         i1 = (int)(s * (c - 1)); i1 = max(0, min(i1, c - 2));
     22        i1 = (int)(s * (c - 1)); i1 = std::max(0, std::min(i1, c - 2));
    2323        double sw = 1.0 / (c - 1);
    2424        double s1 = sw * i1;
  • cpp/frams/neuro/impl/neuroimpl-fuzzy-f0.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    77
    88#include "neuroimpl-fuzzy-f0.h"
    9 #include <common/nonstd_stl.h> //min,max
     9#include <algorithm>
    1010
    1111//this part concerns fuzzy sets transformation
     
    132132                                return -1;
    133133                        if ((k >= inNr) && ((k % 2) == 0))
    134                                 maxOutputNr = max(maxOutputNr, rules[j][k]);
     134                                maxOutputNr = std::max(maxOutputNr, rules[j][k]);
    135135                }
    136136        }
  • cpp/frams/neuro/impl/neuroimpl-fuzzy.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "neuroimpl-fuzzy.h"
    66#include "neuroimpl-fuzzy-f0.h"
    7 #include <common/nonstd_stl.h> //min,max
    87
    98int NI_FuzzyNeuro::countOuts(const Model *m, const Neuro *fuzzy)
     
    109108                        nrFuzzySet = rules[i][j * 2 + 1]; // j*2 moves pointer through each output, +1 moves to nr of fuzzy set
    110109                        inputNr = rules[i][j * 2]; // as above but gives input number
    111                         minimumCut = min(minimumCut, TrapeziumFuzz(nrFuzzySet, getWeightedInputState(inputNr))); // value of membership function for this input and given fuzzy set
     110                        minimumCut = std::min(minimumCut, TrapeziumFuzz(nrFuzzySet, getWeightedInputState(inputNr))); // value of membership function for this input and given fuzzy set
    112111                }
    113112                if ((minimumCut > 1) || (minimumCut < 0))
  • cpp/frams/param/mutableparam.cpp

    r973 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    2222};
    2323#undef FIELDSTRUCT
    24 const int MutableParam::staticprops = ARRAY_LENGTH(pe_tab);
     24const int MutableParam::staticprops = std::size(pe_tab);
    2525
    2626MutableParam::MutableParam(const char*n, const char*g, int gr0)
  • cpp/frams/param/paramobj.cpp

    r1051 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include <frams/param/paramobj.h>
    66#include <frams/util/extvalue.h>
    7 #include <common/nonstd_stl.h>
     7#include <algorithm>
    88       
    99static const char* maybedup(bool dup, const char* src)
     
    232232        const ExtValue *s = &src.fields[0];
    233233        ExtValue *d = &fields[0];
    234         int n = min(numfields, src.numfields);
     234        int n = std::min(numfields, src.numfields);
    235235        for (int i = 0; i < n; i++, d++, s++)
    236236                *d = *s;
  • cpp/frams/util/extvalue.h

    r851 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    88#include "sstring.h"
    99#include <frams/param/param.h>
    10 #include <common/nonstd_stl.h>
    1110#include <common/threads.h>
     11#include <vector>
    1212
    1313#define EXTVALUEUNION
  • cpp/frams/util/multirange.cpp

    r733 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "multirange.h"
    6 #include <common/nonstd_stl.h>
     6#include <algorithm>
    77
    88#include <stdio.h>
     
    230230                break;
    231231        case SAME + JOINBEGIN: // extend 1 range
    232                 setEnd(r1, max(getEnd(r2), end));
     232                setEnd(r1, std::max(getEnd(r2), end));
    233233                break;
    234234        case SAME + JOINEND: // extend 1 range
     
    244244                break;
    245245        case JOINBEGIN: // extend r1
    246                 setEnd(r1, max(end, getEnd(r2)));
     246                setEnd(r1, std::max(end, getEnd(r2)));
    247247                removeRanges(r1 + 1, r2);
    248248                break;
     
    253253        case 0: // extend r2
    254254                setBegin(r2, begin);
    255                 setEnd(r2, max(end, getEnd(r2)));
     255                setEnd(r2, std::max(end, getEnd(r2)));
    256256                removeRanges(r1 + 1, r2 - 1);
    257257                break;
  • cpp/frams/util/sstring-simple.cpp

    r1040 r1130  
    11#include "sstring.h"
    2 #include <common/nonstd_stl.h>
    32#include "extvalue.h"
    43#include <assert.h>
  • cpp/frams/util/sstring.cpp

    r1040 r1130  
    2020// - mutex required to be thread safe
    2121
    22 #include <common/nonstd_stl.h>
    2322#include "extvalue.h"
    2423#include <assert.h>
  • cpp/frams/vm/classes/collectionobj.cpp

    r1076 r1130  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    66#include <common/nonstd_math.h> //sqrt in borland
    77#include <frams/util/validitychecks.h>
    8 #include <common/nonstd_stl.h>
     8#include <algorithm>
    99#include <frams/util/sstringutils.h>
    1010#ifndef NO_VMACHINE
     
    228228                s += d * d;
    229229        }
    230         ret->setDouble(sqrt(s / max(1, data.size() - 1)));
     230        ret->setDouble(sqrt(s / std::max(1, data.size() - 1)));
    231231}
    232232
Note: See TracChangeset for help on using the changeset viewer.