Compare

2つの値をそのうち1つがあと1つと比べて「より大きい、より小さい、等しい」かで比較します。

2つのブール値を扱うためのバージョン:

int Compare(
  const bool  x,        // 1番目の値
  const bool  y          // 2番目の値
  );

2つのchar値を扱うためのバージョン:

int Compare(
  const char  x,        // 1番目の値
  const char  y          // 2番目の値
  );

2つのuchar値を扱うためのバージョン:

int Compare(
  const uchar  x,        // 1番目の値
  const uchar  y        // 2番目の値
  );

2つのshort値を扱うためのバージョン:

int Compare(
  const short x,        // 1番目の値
  const short y        // 2番目の値
  );

2つのushort値を扱うためのバージョン:

int Compare(
  const ushort  x,      // 1番目の値
  const ushort  y        // 2番目の値
  );

2つのcolor値を扱うためのバージョン:

int Compare(
  const color x,        // 1番目の値
  const color y        // 2番目の値
  );

2つのint値を扱うためのバージョン:

int Compare(
  const int x,          // 1番目の値
  const int y          // 2番目の値
  );

2つのuint値を扱うためのバージョン:

int Compare(
  const uint x,        // 1番目の値
  const uint y          // 2番目の値
  );

2つのdatetime値を扱うためのバージョン:

int Compare(
  const datetime x,     // 1番目の値
  const datetime  y      // 2番目の値
  );

2つのlong値を扱うためのバージョン:

int Compare(
  const long x,        // 1番目の値
  const long  y          // 2番目の値
  );

2つのulong値を扱うためのバージョン:

int Compare(
  const ulong  x,        // 1番目の値
  const ulong  y        // 2番目の値
  );

2つの float値を扱うためのバージョン:

int Compare(
  const float  x,        // 1番目の値
  const float  y        // 2番目の値
  );

2つのdouble値を扱うためのバージョン:

int Compare(
  const double  x,      // 1番目の値
  const double y        // 2番目の値
  );

2つのstring値を扱うためのバージョン:

int Compare(
  const string  x,      // 1番目の値
  const string y        // 2番目の値
  );

2つのその他の型の値を扱うためのバージョン:

template<typename T>
int Compare(
  T  x,                  // 1番目の値
  T  y                  // 2番目の値
  );

パラメータ

x

[in]  1番目の値

y

[in]  2番目の値

戻り値

比較された2つの値の比を表す数値を返します。

  • 結果が0より小さい場合、xはyより小さい(x <y)です。
  • 結果がゼロに等しい場合、xはyに等しい(x = y)です。
  • 結果がゼロより大きい場合、xはyより大きい(x> y)です。

注意事項

T型がIComparable<T>インターフェイスを実装するオブジェクトである場合、オブジェクトはそのCompareメソッドに基づいて比較されます。その他のすべての場合には0が返されます。