Beispiel #1
0
        static public void RegisterWizardPane(string header, OptionsPaneCreator creator, int order)
        {
            if (_registeredPanes.Contains(header))
            {
                throw new InvalidOperationException(
                          "Startup Wizard Pane '" + header + "' is already registered.");
            }
            int index = header.LastIndexOf('/');

            if (index > 0)
            {
                string parentHeader = header.Substring(0, index);
                if (!_registeredPanes.Contains(parentHeader))
                {
                    throw new InvalidOperationException(
                              "Can't register Startup Wizard Pane '" + header + "' because parent pane '" +
                              parentHeader + "' was not registered.");
                }
            }
            _registeredPanes[header] = new Pair(order, creator);
            if (_activeWizard != null)
            {
                CreatePane(header);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adjusts the unread count for the specified resource stored in the specified
        /// count map by the specified delta value.
        /// </summary>
        private void AdjustUnreadCount(IResource res, int delta, UnreadState state)
        {
            if (!state.IsPersistent && !state.IsCounterValid(res))
            {
                return;
            }

            int count;

            if (state.IsCounterValid(res) || (state.IsPersistent && !_unreadCountProviders.Contains(res.Type)))
            {
                count = state.GetUnreadCount(res) + delta;
            }
            else
            {
                // this will initiate a new count calculation which will already take into account
                // the new unread state of the resource
                count = state.GetUnreadCount(res);
            }
            if (count >= 0)
            {
                state.UpdateUnreadCounter(res, count);
                if (state.IsPersistent && !_unreadCountProviders.Contains(res.Type))
                {
                    MarkUnreadCounterChanged(res);
                }
            }
        }
Beispiel #3
0
        internal TableStructure(BinaryReader structReader, DBStructure dbStructure)
        {
            _dbStructure = dbStructure;
            _name        = structReader.ReadString();
            _tracer      = new Tracer("(DBUtils) Table structure - " + _name);
            if (_dbStructure.Version >= 3)
            {
                _nextID = structReader.ReadInt32();
            }
            if (_dbStructure.Version >= 18)
            {
                _totalCount = structReader.ReadInt32();
            }
            _dirty = structReader.ReadBoolean();
            int count = structReader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                ColumnStructure column = new ColumnStructure(structReader);
                if (_columns.Contains(column.Name))
                {
                    throw new ColumnAlreadyExistsException("Table structure already contains such column", column.Name);
                }
                _columns.Add(column.Name, column);
            }
            int compoundCount = structReader.ReadInt32();

            for (int i = 0; i < compoundCount; i++)
            {
                string firstColumn  = structReader.ReadString();
                string secondColumn = structReader.ReadString();
                if (_compoundIndexes.Contains(firstColumn))
                {
                    throw new IndexAlreadyExistsException("Table structure already contains such compound index: " +
                                                          firstColumn + " : " + secondColumn);
                }
                _compoundIndexes.Add(firstColumn, secondColumn);
            }
            if (_dbStructure.Version >= 12)
            {
                compoundCount = structReader.ReadInt32();
                for (int i = 0; i < compoundCount; i++)
                {
                    CompoundWithValue compoundWithValue = new CompoundWithValue();
                    compoundWithValue.firstColumn  = structReader.ReadString();
                    compoundWithValue.secondColumn = structReader.ReadString();
                    compoundWithValue.valueColumn  = structReader.ReadString();
                    if (_compoundIndexesWithValue.Contains(compoundWithValue.firstColumn))
                    {
                        throw new IndexAlreadyExistsException("Table structure already contains such compound index with value" +
                                                              compoundWithValue.firstColumn + " : " + compoundWithValue.secondColumn +
                                                              " : " + compoundWithValue.valueColumn);
                    }
                    _compoundIndexesWithValue.Add(compoundWithValue.firstColumn, compoundWithValue);
                }
            }
        }
Beispiel #4
0
 public TableStructure CreateTable(string name)
 {
     if (!_tables.Contains(name))
     {
         TableStructure table = new TableStructure(name, this);
         _tables.Add(name, table);
         return(table);
     }
     throw new TableAlreadyExistsException("Table with this name already exists", name);
 }
Beispiel #5
0
 public ITableDesign CreateTable(string name, TableStructure tblStructure)
 {
     if (!_tables.Contains(name))
     {
         Table table = new Table(this, tblStructure);
         _tables.Add(name, table);
         return(table);
     }
     throw new TableAlreadyExistsException("Database '" + Name + "' already contains '" + name + "' table.", name);
 }
        static void Main(string[] args)
        {
            Populate();
            MyMap.Print();
            Console.WriteLine();
            Console.WriteLine(MyMap.Get("Elephant"));
            Console.WriteLine(MyMap.Get("Kangaroo"));
            Console.WriteLine(MyMap.Get("Giraffe"));
            Console.WriteLine(MyMap.Get("Iguana"));
            Console.WriteLine();
            Console.WriteLine(MyMap.Contains("Elephant"));
            Console.WriteLine(MyMap.Contains("Unicorn"));
            Console.WriteLine(MyMap.Contains("Frog"));
            Console.WriteLine(MyMap.Contains("Iguana"));

            Console.WriteLine();
            MyMap = new HashMap(20);
            Console.WriteLine(MyMap.FirstRepeatedWord("Welcome ???@@##$ to#$% Geeks%$^ for$%^& Geeks"));
            MyMap = new HashMap(20);
            Console.WriteLine(MyMap.FirstRepeatedWord("Once upon a time, there was a brave princess who..."));
            MyMap = new HashMap(20);
            Console.WriteLine(MyMap.FirstRepeatedWord("It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way – in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only..."));
            MyMap = new HashMap(20);
            Console.WriteLine(MyMap.FirstRepeatedWord("It was a queer, sultry summer, the summer they electrocuted the Rosenbergs, and I didn’t know what I was doing in New York..."));

            PopulateTrees();
            CollisionList = TreeIntersection(TreeOne, TreeTwo, 20);
            Console.WriteLine();
            Console.Write("[");
            foreach (string value in CollisionList)
            {
                Console.Write(" {0} ", value);
            }
            Console.WriteLine("]");
            Console.WriteLine();

            PopulateLeftMap();
            MyMap.Print();
            PopulateRightMap();
            RightMap.Print();
            Console.WriteLine("[");
            foreach (var item in MyMap.LeftJoin(RightMap))
            {
                Console.Write("\t[ {0}", item.Key);

                foreach (var item2 in item.Value)
                {
                    Console.Write(" {0} ", item2);
                }

                Console.WriteLine("],");
            }

            Console.WriteLine("]");
        }
Beispiel #7
0
        public static List <ReturnObject> Traverse(HashMap <string> hash1, HashMap <string> hash2)
        {
            List <ReturnObject> list = new List <ReturnObject>();

            for (int i = 0; i < hash1.Map.Length; i++)
            {
                if (hash1.Map != null)
                {
                    Node <KeyValuePair <string, string> > current = hash1.Map[i].Head;
                    while (current != null)
                    {
                        if (hash2.Contains(current.Value.Key))
                        {
                            var    rightValue = hash2.Get(current.Value.Key);
                            string value      = rightValue.ToString();

                            ReturnObject holder = new ReturnObject(
                                current.Value.Key, current.Value.Value,
                                value);
                            list.Add(holder);
                        }
                        else
                        {
                            ReturnObject holder = new ReturnObject(
                                current.Value.Key, current.Value.Value,
                                null);
                            list.Add(holder);
                        }
                        current = current.Next;
                    }
                    return(list);
                }
            }
            return(list);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            IMap <string, Command> commands = new HashMap <string, Command>();

            commands.Add("-c", new Command(new Action <string, string>(CreatePackage), "-if", "-of"));
            commands.Add("-e", new Command(new Action <string, string>(ExtractPackage), "-if", "-of"));
            commands.Add("-E", new Command(new Action <string, string, string>(ExtractEntry), "-if", "-e", "-of"));
            commands.Add("-a", new Command(new Action <string, string, string>(AddEntry), "-of", "-if", "-e"));
            commands.Add("-l", new Command(new Action <string>(ListEntries), "-if"));
            commands.Add("-h", new Command(new Action(PrintHelp)));

            if (args == null || args.Length == 0)
            {
                args = new string[] { "-h" };
            }

            Command command = null;

            if (commands.Contains(args[0]))
            {
                command = commands[args[0]];
            }

            if (command == null || !command.Invoke(args))
            {
                PrintHelp();
            }
        }
Beispiel #9
0
        public bool SearchUser(ulong key, out Account value)
        {
            if (!hashMap.Contains(key))
            {
                //Если в ОЗУ нет хеша
                HashMap <Account> tempHashMap = new HashMap <Account>();
                foreach (var i in Directory.GetFiles(PathData, $"*.{fileDataType}"))
                {
                    tempHashMap.Deserialize(i);

                    if (tempHashMap.Contains(key))
                    {
                        value = tempHashMap.GetValueByKey(key);
                        return(true);
                    }
                }

                value = null;
                return(false);
            }
            else
            {
                value = hashMap.GetValueByKey(key);
                return(true);
            }
        }
Beispiel #10
0
        public void AddOneElementToEmptyMap(int key, string value)
        {
            var map = new HashMap <int, string>();

            map.Add(key, value);
            map.Contains(key).Should().BeTrue();
        }
Beispiel #11
0
 public void  UnregisterSearchProvider(ISearchProvider host)
 {
     if (_SearchProviders.Contains(host))
     {
         _SearchProviders.Remove(host);
     }
 }
Beispiel #12
0
 public CheckBoxState GetItemCheckState(object item)
 {
     if (!_checkStates.Contains(item))
     {
         return(GetDefaultCheckState(item));
     }
     return((CheckBoxState)_checkStates [item]);
 }
Beispiel #13
0
 /// <summary>
 /// Returns the resource type for which the rules are created, given the resource type
 /// for which the dialog is invoked.
 /// </summary>
 /// <param name="resType">The resource type for which the dialog is invoked.</param>
 /// <returns>The resource type for which the rules are created.</returns>
 public string GetRuleResourceType(string resType)
 {
     if (_ruleResourceTypes.Contains(resType))
     {
         return((string)_ruleResourceTypes [resType]);
     }
     return(resType);
 }
Beispiel #14
0
        public void ContainsTest()
        {
            HashMap <int, string> map = new HashMap <int, string>();

            map.Add(1, "a");
            map.Add(2, "b");
            map.Add(3, "c");

            KeyValuePair <int, string> containsA = new KeyValuePair <int, string>(1, "a");
            KeyValuePair <int, string> containsB = new KeyValuePair <int, string>(1, "b");

            Assert.True(map.Contains(containsA));
            Assert.False(map.Contains(containsB));

            Assert.True(map.ContainsKey(1));
            Assert.False(map.ContainsKey(4));
        }
Beispiel #15
0
        private DictionaryServer(params string[] dictionaries)
        {
            /**
             * try to load compiled dictionaries
             */
            if (File.Exists(OMEnv.CompiledDicsFileName))
            {
                try
                {
                    HashMap    compiledDicNames = new HashMap();
                    FileStream compiled         = IOTools.OpenRead(OMEnv.CompiledDicsFileName, 0x10000);
                    using ( compiled )
                    {
                        BinaryReader reader = new BinaryReader(compiled, Encoding.Unicode);
                        string       name;
                        while ((name = reader.ReadString()).Length > 0)
                        {
                            compiledDicNames[name] = reader.ReadInt64();
                        }
                        bool need2Rebuild = false;
                        // check whether all necessary dictionaries are compiled
                        foreach (string dictionary in dictionaries)
                        {
                            if (!compiledDicNames.Contains(dictionary) ||
                                (long)compiledDicNames[dictionary] !=
                                IOTools.GetLastWriteTime(IOTools.GetFileInfo(dictionary)).Ticks)
                            {
                                need2Rebuild = true;
                                break;
                            }
                        }
                        if (!need2Rebuild)
                        {
                            int charCount = reader.ReadInt32();
                            DicBase = reader.ReadChars(charCount);
                            int intCount = reader.ReadInt32();
                            BaseIndices = new int[intCount];
                            for (int i = 0; i < intCount; ++i)
                            {
                                BaseIndices[i] = reader.ReadInt32();
                            }
                            if (BaseIndices.Length >= 2)
                            {
                                LastWordCharIndex = BaseIndices[BaseIndices.Length - 2];
                                FirstDicChar      = DicBase[0];
                                LastDicChar       = DicBase[LastWordCharIndex];
                            }
                            return;
                        }
                    }
                }
                catch {}
            }

            DefaultDictionariesLoading(dictionaries);
            SaveCompiledDictionaries(dictionaries);
        }
        public void Test_That_Contains_Returns_False_When_Key_Not_Present()
        {
            HashMap testMap = new HashMap(50);

            string testKey = "key";
            string testVal = "val";

            testMap.Add(testKey, testVal);

            Assert.False(testMap.Contains("Ameilia"));
        }
        public void Remove()
        {
            HashMap <string, int> test = new HashMap <string, int>();

            test.Add("One", 1);
            test.Add("Two", 2);
            test.Add("Three", 3);
            test.Add("Four", 4);
            test.Add("Five", 5);

            test.Remove("One");
            test.Remove("Three");
            test.Remove("Five");

            Assert.IsFalse(test.Contains("One"));
            Assert.AreEqual(test.Get("Two"), 2);
            Assert.IsFalse(test.Contains("Three"));
            Assert.AreEqual(test.Get("Four"), 4);
            Assert.IsFalse(test.Contains("Five"));
        }
        public void Test_That_Add_Results_In_Value_Being_Added_To_Map()
        {
            HashMap testMap = new HashMap(50);

            string testKey = "key";
            string testVal = "val";

            testMap.Add(testKey, testVal);

            Assert.True(testMap.Contains(testKey));
        }
Beispiel #19
0
 private void AddDefaultFont( )
 {
     if (_fontNum == -1)
     {
         return;
     }
     if (_fonts.Contains(_fontNum))
     {
         return;
     }
     _fonts.Add(_fontNum, _defaultEncoding);
 }
Beispiel #20
0
 static void Main(string[] args)
 {
     HashMap<int, int> test = new HashMap<int, int>();
     test.Add(1, 2);
     test.Add(2, 3);
     test.Add(3, 4);
     test.Add(4, 5);
     Console.WriteLine(test.Contains(22));
     foreach (var item in test)
     {
         Console.WriteLine($"{item.Key}    {item.Value}");
     }
 }
Beispiel #21
0
        public void TestHashMap()
        {
            // update hashtable
            HashMap T   = new HashMap();
            Random  Rnd = new Random();
            long    i   = 0;

            for ( ; i < 1000; ++i)
            {
                T[i] = Rnd.Next(10000000).ToString();
            }

            // test IEnumerable implementation
            int iCount = 0;

            foreach (HashMap.Entry E in T)
            {
                ++iCount;
                if (E.Value == null)
                {
                    throw new Exception("Null value in HashMap");
                }
            }
            if (iCount != 1000)
            {
                throw new Exception("HashMap as IEnumerable returns invalid entries");
            }

            // test IDictionary implementation
            if (!T.Contains(100L) || !T.Contains(200L))
            {
                throw new Exception("HashMap's key resolution error");
            }
            if (T.Count != 1000)
            {
                throw new Exception("HashMap.Count returned invalid value: " + T.Count.ToString());
            }
        }
Beispiel #22
0
        private static Icon DoGetResourceIcon(IResource resource)
        {
            string flagID = resource.GetStringProp("FlagId");

            if (flagID != null)
            {
                if (!_flagHashMap.Contains(flagID))
                {
                    return(LoadFlagIcon(resource));
                }
                return((Icon)_flagHashMap [flagID]);
            }
            return(null);
        }
        /// <summary>
        /// This method traverses through the 2nd list and adds all collisions to a list
        /// </summary>
        /// <param name="collisionMap">Hash Table storing the values of the first tree</param>
        /// <param name="current">current position in 2nd tree during traverse</param>
        /// <param name="collisionList">List of collisions</param>
        /// <returns>List of collisions</returns>
        public static List <string> BuildCollisionList(HashMap collisionMap, Node <string> current, List <string> collisionList)
        {
            if (current != null)
            {
                if (collisionMap.Contains(current.Value))
                {
                    collisionList.Add(current.Value);
                }

                BuildCollisionList(collisionMap, current.LeftChild, collisionList);
                BuildCollisionList(collisionMap, current.RightChild, collisionList);
            }

            return(collisionList);
        }
Beispiel #24
0
 /// <summary>
 /// Traverse the second binary tree.  If collision occurs put double value into a list
 /// </summary>
 /// <param name="root"> tree 2 root node </param>
 /// <param name="hashMap"> hashMap with values from tree 1 </param>
 /// <param name="list"> empty list </param>
 /// <returns></returns>
 public static List <int> CompareTree2(DataStructures.Trees.Node <int> root, HashMap <int> hashMap, List <int> list)
 {
     if (hashMap.Contains(root.Value))
     {
         list.Add(root.Value);
     }
     if (root.Left != null)
     {
         CompareTree2(root.Left, hashMap, list);
     }
     if (root.Right != null)
     {
         CompareTree2(root.Right, hashMap, list);
     }
     return(list);
 }
Beispiel #25
0
        /**
         * Adds the icon to the list if it was not already added and returns its index.
         */

        private int AddIconIfNew(Icon icon)
        {
            if (icon == null)
            {
                return(0);
            }

            if (_iconMap.Contains(icon))
            {
                return((int)_iconMap [icon]);
            }
            int index = _imageList.Images.Count;

            _imageList.Images.Add(icon);
            _iconMap [icon] = index;
            return(index);
        }
Beispiel #26
0
        /// <summary>
        /// Iterate over the array the words checking for repeats against a hashMap
        /// </summary>
        /// <param name="inputArray"> string[] of words </param>
        /// <returns> first word repeated, or null </returns>
        public static string FindRepeat(string[] inputArray)
        {
            HashMap <string> hashMap = new HashMap <string>(1024);

            foreach (var word in inputArray)
            {
                if (hashMap.Contains(word))
                {
                    return(word);
                }
                else
                {
                    hashMap.Set(word, word);
                }
            }
            return(null);
        }
        //Chapter 1 Arrays and Strings
        public static bool isUniqueWithHashTable(string str)
        {
            HashMap hashMap  = new HashMap();
            bool    isUnique = true;

            foreach (char c in str)
            {
                if (hashMap.Contains(c))
                {
                    isUnique = false;
                    break;
                }
                else
                {
                    hashMap.Add(c);
                    isUnique = true;
                }
            }
            return(isUnique);
        }
Beispiel #28
0
        private void RecalcOnNodeChanged(JetListViewColumn col, JetListViewColumn indentCol, int fixedWidth, JetListViewNode paramNode)
        {
            int oldWidth = -1;

            lock ( _sizeToContentItemWidths )
            {
                HashMap widths = (HashMap)_sizeToContentItemWidths [col];
                if (widths != null && widths.Contains(paramNode.Data))
                {
                    oldWidth = (int)widths [paramNode.Data];
                }
            }
            if (oldWidth == col.Width)
            {
                RecalcAll(col, indentCol, fixedWidth, null);
            }
            else
            {
                int desiredWidth = GetDesiredWidthIndented(col, indentCol, paramNode, fixedWidth);
                col.Width = Math.Max(col.Width, desiredWidth);
            }
        }
Beispiel #29
0
        public void Add_A_Value_To_Hash_Map_And_Prove_Its_There()
        {
            HashMap <string> testMap = PopulatedHashMap();

            Assert.True(testMap.Contains("Ethel"));
        }
Beispiel #30
0
        private void SpatialQuery()
        {
            DF3DApplication app = DF3DApplication.Application;

            if (app == null || app.Current3DMapControl == null)
            {
                return;
            }

            try
            {
                HashMap        hashMap = new HashMap();
                IRowBuffer     buffer  = null;
                IFdeCursor     cursor  = null;
                ISpatialFilter filter  = null;
                IGeometry      geo2D   = this._drawTool.GetGeo();
                if (geo2D != null && geo2D.GeometryType == gviGeometryType.gviGeometryPolygon)
                {
                    IPolygon polygon = geo2D as IPolygon;
                    if (polygon != null)
                    {
                        DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer;
                        if (featureClassInfo != null)
                        {
                            IFeatureClass featureClass = featureClassInfo.GetFeatureClass();
                            if (featureClass != null)
                            {
                                string typeName = featureClassInfo.GetFacilityClassName();
                                if (typeName == "PipeLine" || typeName == "PipeNode" || typeName == "PipeBuild" || typeName == "PipeBuild1")
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        GeometryField = "Shape",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelIntersects,
                                        Geometry      = polygon.Clone2(gviVertexAttribute.gviVertexAttributeNone)
                                    };
                                }
                                else
                                {
                                    filter = new SpatialFilterClass
                                    {
                                        Geometry      = polygon,
                                        GeometryField = "Geometry",
                                        SpatialRel    = gviSpatialRel.gviSpatialRelEnvelope
                                    };
                                }
                                filter.SubFields = featureClass.FidFieldName;
                                cursor           = featureClass.Search(filter, true);
                                while ((buffer = cursor.NextRow()) != null)
                                {
                                    int featureId = int.Parse(buffer.GetValue(0).ToString());
                                    if (hashMap.Contains(featureClassInfo))
                                    {
                                        System.Collections.Generic.List <int> list = hashMap[featureClassInfo] as System.Collections.Generic.List <int>;
                                        if (!list.Contains(featureId))
                                        {
                                            list.Add(featureId);
                                        }
                                    }
                                    else
                                    {
                                        System.Collections.Generic.List <int> list2 = new System.Collections.Generic.List <int>();
                                        if (!list2.Contains(featureId))
                                        {
                                            list2.Add(featureId);
                                        }
                                        hashMap[featureClassInfo] = list2;
                                    }
                                }
                            }
                        }
                    }
                    SelectCollection.Instance().UpdateSelection(hashMap);
                    RenderControlEditServices.Instance().SetEditorPosition(SelectCollection.Instance().FcRowBuffersMap);
                    this.Clear();
                }
                if (buffer != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(buffer);
                }
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                }
                if (filter != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(filter);
                }
            }
            catch (Exception ex)
            {
                LoggingService.Error(ex.Message);
            }
        }
 public void AddTest()
 {
     hash.Add(1234);
     Assert.IsTrue(hash.Contains(1234));
 }