From 79fc3f303e5699c3ee0cee7fb419a4ce4e209ef4 Mon Sep 17 00:00:00 2001 From: 7u83 <7u83@maiil.ru> Date: Sun, 23 Dec 2018 10:46:53 +0100 Subject: [PATCH] Codee sorting and removal off Scollection --- src/opensesim/world/GodWorld.java | 65 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/opensesim/world/GodWorld.java b/src/opensesim/world/GodWorld.java index 018c76e..391b713 100644 --- a/src/opensesim/world/GodWorld.java +++ b/src/opensesim/world/GodWorld.java @@ -35,7 +35,7 @@ import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import opensesim.sesim.interfaces.GetJson; -import opensesim.util.Scollection; + import opensesim.util.SeSimException; import opensesim.util.idgenerator.IDGenerator; import opensesim.world.scheduler.EventListener; @@ -75,13 +75,11 @@ public class GodWorld implements GetJson, World { /* HashSet assetsById = new HashSet<>(); HashMap assetsBySymbol = new HashMap<>(); */ - Scollection assets = new Scollection<>(); - IDGenerator assetIdGenerator = new IDGenerator(); + + IDGenerator orderIdGenerator = new IDGenerator(); - HashSet assetPairs = new HashSet<>(); - private Scheduler scheduler = new Scheduler(); /** @@ -131,7 +129,7 @@ public class GodWorld implements GetJson, World { continue; } - assets.add(a.getSymbol(), a); + assets.put(a.getSymbol(), a); } // Read exchanges @@ -194,7 +192,7 @@ public class GodWorld implements GetJson, World { throw new SeSimException("Already defined"); } - assets.add(a.getSymbol(), a); + assets.put(a.getSymbol(), a); return a; } @@ -221,27 +219,6 @@ public class GodWorld implements GetJson, World { return Collections.unmodifiableCollection(exchanges.values()); } - // -------------------------------------------------------------------- - // Assets - // -------------------------------------------------------------------- - @Override - public Collection getAssetCollection() { - return assets.getCollection(); //Collections.unmodifiableCollection(assetsById); - } - - @Override - public AbstractAsset getAssetBySymbol(String symbol) { - return this.assets.get(symbol); - } - - public Collection getAssetPairsCollection() { - return Collections.unmodifiableCollection(assetPairs); - } - - public void add(AssetPair pair) { - assetPairs.add(pair); - } - public Exchange addExchange(String symbol) throws SeSimException { for (Exchange ex : getExchangeCollection()) { if (ex.getSymbol().equals(symbol)) { @@ -254,6 +231,35 @@ public class GodWorld implements GetJson, World { // return ex; return null; } + + // -------------------------------------------------------------------- + // Assets + // -------------------------------------------------------------------- + private final HashMap assets = new HashMap<>(); + + @Override + public Collection getAssetCollection() { + return Collections.unmodifiableCollection(assets.values()); + } + + @Override + public AbstractAsset getAssetBySymbol(String symbol) { + return this.assets.get(symbol); + } + + // -------------------------------------------------------------------- + // AssetsPairs + // -------------------------------------------------------------------- + private final HashSet asset_pairs = new HashSet<>(); + + public Collection getAssetPairsCollection() { + return Collections.unmodifiableCollection(asset_pairs); + } + + public void add(AssetPair pair) { + asset_pairs.add(pair); + } + /* public AbstractAsset createAsset(long key, JSONObject cfg) throws SeSimException{ if (key!=masterkey) @@ -369,6 +375,9 @@ public class GodWorld implements GetJson, World { // -------------------------------------------------------------------- // Stuff belonging to accounts // -------------------------------------------------------------------- + + + // -------------------------------------------------------------------- // Pseudo random generator stuff // --------------------------------------------------------------------