/// <summary> /// @brief コンストラクタ /// </summary> /// <param name="container">自身を組み込むコンテナ</param> /// <param name="player">親</param> /// <param name="position">初期位置</param> public Bit(GameContainer container, Player player, BitIndex index, GameContainer lazer) : base(container) { Energy = MaxEnergy; // 2秒分 Player = player; Index = index; ShotCounter = 0; Speed = 5.0f; Rot = 90; Angle = Rot * -(float)Math.PI / 180; Lazer = lazer; IsDock = true; if (index == BitIndex.BIT_LEFT) { Position.LocalPosition = new Vector3 { x = -10.0f, y = -5.0f, z = 0.0f }; container.Name = "BitLeft"; } else { Position.LocalPosition = new Vector3 { x = 10.0f, y = -5.0f, z = 0.0f }; container.Name = "BitRight"; } }
public void TestGetDf61Infos() { for (int i = 0; i < this.df61BitWorker.Length(); i++) { BitIndex bi = this.df61BitWorker[i]; logger.Debug($"{0}", bi); } }
public ClothRoot(Storage storage) : base(storage) { colorIndex = storage.CreateBitIndex(); shapeIndex = storage.CreateBitIndex(); clothOidIndex = storage.CreateFieldIndex(typeof(Cloth), "Oid", true); patternIndex = storage.CreateFieldIndex(typeof(Cloth), "Pattern", false); pathIndex = storage.CreateFieldIndex(typeof(Cloth), "Path", true); colorNumIndex = storage.CreateFieldIndex(typeof(Cloth), "ColorNum", false); registerInfoOidIndex = storage.CreateFieldIndex(typeof(RegisterInfo), "Oid", true); registerInfoNameIndex = storage.CreateFieldIndex(typeof(RegisterInfo), "Name", true); }
static BitIndex() { int offset = 0; int counter = 0; m_Cache = new BitIndex[LOOKUP_SIZE]; for (int x = 0; x < m_Cache.Length; ++x) { m_Cache[x] = new BitIndex((byte)offset, (byte)counter); ++counter; if (counter == 32) { counter = 0; ++offset; } } }
/// <summary> /// Find list of Cloth object by shapes. /// NOTES: There are two rules for clothes to be selected: /// <list type="number"> /// <item>It should contains all shapes in <code>shapes</code>.</item> /// <item>It should not contains any shapes in <code>notShapes</code>.</item> /// </list> /// </summary> /// <param name="shapes">The shapes contained by clothes.</param> /// <param name="notShapes">The shapes NOT contained by clothes.</param> /// <returns>Cloth objects list; empty list if none found.</returns> public List <Cloth> FindAllByShapes(ShapeEnum shapes, ShapeEnum notShapes) { Storage storage = DaoHelper.Instance.DbStorage; ClothRoot root = (ClothRoot)storage.Root; List <Cloth> clothes = new List <Cloth>(); BitIndex shapeIndex = root.ShapeIndex; if (shapeIndex.Count > 0) { foreach (Cloth cloth in shapeIndex.Select((int)shapes, (int)notShapes)) { clothes.Add(cloth); } } return(clothes); }
/// <summary> /// Find list of Cloth object by colors. /// NOTES: There are two rules for clothes to be selected: /// <list type="number"> /// <item>It should contains all colors in <code>colors</code>.</item> /// <item>It should not contains any colors in <code>notColors</code>.</item> /// </list> /// </summary> /// <param name="colors">The colors contained by clothes.</param> /// <param name="notColors">The colors NOT contained by clothes.</param> /// <returns>Cloth objects list; empty list if none found.</returns> public List <Cloth> FindAllByColors(ColorEnum colors, ColorEnum notColors) { Storage storage = DaoHelper.Instance.DbStorage; ClothRoot root = (ClothRoot)storage.Root; List <Cloth> clothes = new List <Cloth>(); BitIndex colorIndex = root.ColorIndex; // Console.WriteLine(colorIndex.Count); if (colorIndex.Count > 0) { foreach (Cloth cloth in colorIndex.Select((int)colors, (int)notColors)) { clothes.Add(cloth); } } return(clothes); }
static public void Main(string[] args) { Storage db = StorageFactory.Instance.CreateStorage(); db.Open("testbit.dbs", pagePoolSize); Catalogue root = (Catalogue)db.Root; if (root == null) { root = new Catalogue(); #if USE_GENERICS root.optionIndex = db.CreateBitIndex <Car>(); root.modelIndex = db.CreateFieldIndex <string, Car>("model", true); #else root.optionIndex = db.CreateBitIndex(); root.modelIndex = db.CreateFieldIndex(typeof(Car), "model", true); #endif db.Root = root; } #if USE_GENERICS BitIndex <Car> index = root.optionIndex; #else BitIndex index = root.optionIndex; #endif DateTime start = DateTime.Now; long rnd = 1999; int i, n; Options selectedOptions = Options.TURBO | Options.DISEL | Options.FWD | Options.ABS | Options.EBD | Options.ESP | Options.AIR_COND | Options.HATCHBACK | Options.CLASS_C; Options unselectedOptions = Options.AUTOMATIC; for (i = 0, n = 0; i < nRecords; i++) { rnd = (3141592621L * rnd + 2718281829L) % 1000000007L; Options options = (Options)rnd; Car car = new Car(); car.model = Convert.ToString(rnd); car.options = options; root.modelIndex.Put(car); root.optionIndex[car] = (int)options; if ((options & selectedOptions) == selectedOptions && (options & unselectedOptions) == 0) { n += 1; } } Console.WriteLine("Elapsed time for inserting " + nRecords + " records: " + (DateTime.Now - start)); start = DateTime.Now; i = 0; foreach (Car car in root.optionIndex.Select((int)selectedOptions, (int)unselectedOptions)) { Debug.Assert((car.options & selectedOptions) == selectedOptions); Debug.Assert((car.options & unselectedOptions) == 0); i += 1; } Console.WriteLine("Number of selected cars: " + i); Debug.Assert(i == n); Console.WriteLine("Elapsed time for bit search through " + nRecords + " records: " + (DateTime.Now - start)); start = DateTime.Now; i = 0; foreach (Car car in root.modelIndex) { root.optionIndex.Remove(car); car.Deallocate(); i += 1; } Debug.Assert(i == nRecords); root.optionIndex.Clear(); Console.WriteLine("Elapsed time for removing " + nRecords + " records: " + (DateTime.Now - start)); db.Close(); }
public static bool IsBitSet(this byte i, BitIndex index) { return((i & 1 << (byte)index) != 0); }
public void Update(Cloth cloth, Cloth newCloth) { Storage storage = DaoHelper.Instance.DbStorage; ClothRoot root = (ClothRoot)storage.Root; FieldIndex clothOidIndex = root.ClothOidIndex; if (null == cloth || !clothOidIndex.Contains(cloth)) { return; } FieldIndex patternIndex = root.PatternIndex; BitIndex colorIndex = root.ColorIndex; BitIndex shapeIndex = root.ShapeIndex; FieldIndex pathIndex = root.PathIndex; FieldIndex colorNumIndex = root.ColorNumIndex; storage.BeginThreadTransaction(TransactionMode.Exclusive); try { // Pattern if (cloth.Pattern != null) { if (!cloth.Pattern.Equals(newCloth.Pattern)) { patternIndex.Remove(cloth); cloth.Pattern = newCloth.Pattern; patternIndex.Put(cloth); } } else if (newCloth.Pattern != null) { cloth.Pattern = newCloth.Pattern; patternIndex.Put(cloth); } // ColorNum if (cloth.ColorNum != newCloth.ColorNum) { colorNumIndex.Remove(cloth); cloth.ColorNum = newCloth.ColorNum; colorNumIndex.Put(cloth); } // Path if (cloth.Path != null) { if (!cloth.Path.Equals(newCloth.Path)) { pathIndex.Remove(cloth); cloth.Path = newCloth.Path; pathIndex.Set(cloth); } } else if (newCloth.Path != null) { cloth.Path = newCloth.Path; pathIndex.Set(cloth); } // Colors if (cloth.Colors != newCloth.Colors) { colorIndex.Remove(cloth); cloth.Colors = newCloth.Colors; colorIndex[cloth] = (int)cloth.Colors; } // Shapes if (cloth.Shapes != newCloth.Shapes) { shapeIndex.Remove(cloth); cloth.Shapes = newCloth.Shapes; shapeIndex[cloth] = (int)cloth.Shapes; } // Name if ((cloth.Name != null && !cloth.Name.Equals(newCloth.Name)) || (cloth.Name == null && newCloth.Name != null)) { cloth.Name = newCloth.Name; } // RGBSeparateColorVector if (newCloth.RGBSeparateColorVector != null && !newCloth.RGBSeparateColorVector.Equals(cloth.RGBSeparateColorVector)) { cloth.RGBSeparateColorVector = newCloth.RGBSeparateColorVector; } // RGBColorVector if (newCloth.RGBColorVector != null && !newCloth.RGBColorVector.Equals(cloth.RGBColorVector)) { cloth.RGBColorVector = newCloth.RGBColorVector; } // HSVColorVector if (newCloth.HSVColorVector != null && !newCloth.HSVColorVector.Equals(cloth.HSVColorVector)) { cloth.HSVColorVector = newCloth.HSVColorVector; } // HSVAynsColorVector if (newCloth.HSVAynsColorVector != null && !newCloth.HSVAynsColorVector.Equals(cloth.HSVAynsColorVector)) { cloth.HSVAynsColorVector = newCloth.HSVAynsColorVector; } // HLSColorVector if (newCloth.HLSColorVector != null && !newCloth.HLSColorVector.Equals(cloth.HLSColorVector)) { cloth.HLSColorVector = newCloth.HLSColorVector; } // DaubechiesWaveletVector if (newCloth.DaubechiesWaveletVector != null && !newCloth.DaubechiesWaveletVector.Equals(cloth.DaubechiesWaveletVector)) { cloth.DaubechiesWaveletVector = newCloth.DaubechiesWaveletVector; } // GaborVector if (newCloth.GaborVector != null && !newCloth.GaborVector.Equals(cloth.GaborVector)) { cloth.GaborVector = newCloth.GaborVector; } // CooccurrenceVector if (newCloth.CooccurrenceVector != null && !newCloth.CooccurrenceVector.Equals(cloth.CooccurrenceVector)) { cloth.CooccurrenceVector = newCloth.CooccurrenceVector; } cloth.UpdateTime = (0 == newCloth.UpdateTime.Ticks) ? DateTime.UtcNow : newCloth.UpdateTime; cloth.Modify(); storage.EndThreadTransaction(); } catch (Exception e) { // do some log storage.RollbackThreadTransaction(); } }