2つのクラスAuction
とがありLot
ます。データの保存方法:このデータ構造をBid(lot.Max)で簡単に検索し、関連するClientオブジェクトを返すことができるように、Client(Thread)とBid(int)を保存しますか?
public class Lot {
public HashMap<ClientThread, Integer> mapBids= new HashMap<ClientThread, Integer>();
}
public class Auction {
List<Lot> lots = new ArrayList<Lot>();
for(Lot lot: lots){
int lastBid = lot.BiggestBid;
...
// How to get Client object which has "lot.BiggestBid" ?
System.out.println(
lot.mapBids.get(lot.BiggestBid).someClientThreadMethod(args)); // wrong
}
}
おそらく、とLot
のペアを保持し、持っている人を返すことができるデータ構造が必要です...Client
BiggestBid
Client
BiggestBid
クライアントやBiggestBidは、一部のエンティティで同じにすることができます。
たぶん、2つの並列アレイが機能します。