掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Generics.Collections.TDictionary の ContainsValue (ID:40016)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
にしのさん、回答ありがとうございます。 type TCity = record public Country : string; Latitude : Integer; Longitude : Integer; class operator Equal ( A, B : TCity ) : Boolean; class operator NotEqual( A, B : TCity ) : Boolean; end; class operator TCity.Equal(A, B: TCity): Boolean; begin Result := false; if (A.Country = B.Country ) and (A.Latitude = B.Latitude ) and (A.Longitude= B.Longitude) then Result := True; end; class operator TCity.NotEqual(A, B: TCity): Boolean; begin Result := True; if (A.Country = B.Country ) and (A.Latitude = B.Latitude ) and (A.Longitude= B.Longitude) then Result := false; end; とすると、 if City=City2 then ・・・ のようにできるんですね。(Delphiで演算子のオーバーロードは初めて使いました) しかしながら、ウェンドレン さんの仰る様に動作は変わりませんでした。 ウェンドレン さん、非常に丁寧な解説ありがとうございます。 >stringの部分を静的なChar配列に変更すること でできることはわかりました。内部実装はバイナリ比較なんですね。 >Create時の引数でComparerを渡してやること は、高度すぎて私には無理でした・・ググってもサンプルが見つからなかったので・・
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.