commonlib/misc.h

changeset 65
e679dd5cd159
parent 56
bdbbde5f754e
equal deleted inserted replaced
64:c55e46b7ddeb 65:e679dd5cd159
27 void commonInit(); 27 void commonInit();
28 QString basename (const QString& path); 28 QString basename (const QString& path);
29 bool confirm (const QString& text); 29 bool confirm (const QString& text);
30 QString getBinaryPath (QWidget* parent); 30 QString getBinaryPath (QWidget* parent);
31 void assimilateWadPaths (QStringList& wadpaths); 31 void assimilateWadPaths (QStringList& wadpaths);
32
33 //
34 // -----------------------------------------------------------------------------
35 //
36
37 template<typename T>
38 T clamp (T a, T min, T max)
39 {
40 return (a > max) ? max : (a < min) ? min : a;
41 }
42
43 //
44 // -----------------------------------------------------------------------------
45 //
46
47 template<typename T>
48 T min (T a, T b)
49 {
50 return (a < b) ? a : b;
51 }
52
53 //
54 // -----------------------------------------------------------------------------
55 //
56
57 template<typename T>
58 T max (T a, T b)
59 {
60 return (a > b) ? a : b;
61 }
62
63 //
64 // -----------------------------------------------------------------------------
65 //
66
67 template<typename T>
68 T abs (T a)
69 {
70 return (a < 0) ? -a : a;
71 }

mercurial