Example #1
0
        public static Node GetByIndex(BaseRedBlackTree <Node> tree, int index, GetCount getCount)
        {
            if (index < 0 || index >= tree.Count)
            {
                throw new ArgumentException($"Index out of range {index} [0-{tree.Count})");
            }

            Node node = tree.Root;

            while (true)
            {
                if (node.Left != null && index < getCount(node.Left))
                {
                    node = node.Left;
                    continue;
                }

                if (node.Right == null)
                {
                    return(node);
                }

                index -= getCount(node) - getCount(node.Right);
                if (index < 0)
                {
                    return(node);
                }

                node = node.Right;
            }
        }
Example #2
0
        public Samples(GetCount getCount, SampleIndexer sampleIndexer, IEnumerator enumerator)
        {
            if (getCount == null)
            {
                throw new ArgumentNullException("getCount");
            }
            if (sampleIndexer == null)
            {
                throw new ArgumentNullException("sampleIndexer");
            }
            if (enumerator == null)
            {
                throw new ArgumentNullException("enumerator");
            }

            var inTypeName = typeof(T).FullName;

            if (!typeCheck.IsMatch(inTypeName))
            {
                throw new Exception("T can only be of type: byte, sbyte, short, ushort, int, uint, long, ulong, float or double.");
            }

            this.getCount      = getCount;
            this.sampleIndexer = sampleIndexer;
            sampleEnumerator   = enumerator;
        }
 public void GetLiveCount(GetCount count)
 {
     for (int i = 0; i < 100; i++)
     {
         count(i);
     }
 }
Example #4
0
 public TCPService(int portNumber, int maxConnections, NewConnection newConnection, GetCount getCount)
 {
     PortNumber = portNumber;
     MaxConnections = maxConnections;
     AcceptedConnections = 0;
     OnNewConnection = newConnection;
     GetConnectCount = getCount;
 }
 public TCPService(int portNumber, int maxConnections, NewConnection newConnection, GetCount getCount)
 {
     PortNumber          = portNumber;
     MaxConnections      = maxConnections;
     AcceptedConnections = 0;
     OnNewConnection     = newConnection;
     GetConnectCount     = getCount;
 }
Example #6
0
        public int GetRowCount(IFeatureClass inFC)
        {
            GetCount gc = new GetCount();

            gc.in_rows = inFC;
            this.RunProcess(gc, null);
            return(gc.row_count);
        }
Example #7
0
        public int GetRowCount(string inFileName)
        {
            GetCount gc = new GetCount();

            this.MakeLayer(inFileName, this.tempLayer1);
            gc.in_rows = this.tempLayer1;
            this.RunProcess(gc, null);
            return(gc.row_count);
        }
Example #8
0
File: Test.cs Project: e2wugui/zeze
        private int GetCurrentCount()
        {
            var r = new GetCount();

            while (true)
            {
                try
                {
                    Agent.SendForWait(r).Task.Wait();
                    return(r.ResultCode);
                }
                catch (Exception _)
                {
                }
            }
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:IndexConnector" /> class.
        /// </summary>
        /// <param name="getWordFetcher">The GetWordFetcher delegate.</param>
        /// <param name="getSize">The GetSize delegate.</param>
        /// <param name="getCount">The GetCount delegate.</param>
        /// <param name="clearIndex">The ClearIndex delegate.</param>
        /// <param name="deleteData">The DeleteDataForDocument delegate.</param>
        /// <param name="saveData">The SaveData delegate.</param>
        /// <param name="tryFindWord">The TryFindWord delegate.</param>
        public IndexConnector(GetWordFetcher getWordFetcher, GetSize getSize, GetCount getCount, ClearIndex clearIndex,
                              DeleteDataForDocument deleteData, SaveDataForDocument saveData, TryFindWord tryFindWord)
        {
            if (getWordFetcher == null)
            {
                throw new ArgumentNullException("getWordFetcher");
            }

            if (getSize == null)
            {
                throw new ArgumentNullException("getSize");
            }

            if (getCount == null)
            {
                throw new ArgumentNullException("getCount");
            }

            if (clearIndex == null)
            {
                throw new ArgumentNullException("clearIndex");
            }

            if (deleteData == null)
            {
                throw new ArgumentNullException("deleteData");
            }

            if (saveData == null)
            {
                throw new ArgumentNullException("saveData");
            }

            if (tryFindWord == null)
            {
                throw new ArgumentNullException("tryFindWord");
            }

            this.getWordFetcher = getWordFetcher;
            this.getSize        = getSize;
            this.getCount       = getCount;
            this.clearIndex     = clearIndex;
            this.deleteData     = deleteData;
            this.saveData       = saveData;
            this.tryFindWord    = tryFindWord;
        }
Example #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (GetID != 0)
            {
                hash ^= GetID.GetHashCode();
            }
            if (GetCount != 0)
            {
                hash ^= GetCount.GetHashCode();
            }
            if (GetOdds != 0)
            {
                hash ^= GetOdds.GetHashCode();
            }
            return(hash);
        }
Example #11
0
        public Samples(IList <T> samples)
        {
            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            var inTypeName = typeof(T).FullName;

            if (!typeCheck.IsMatch(inTypeName))
            {
                throw new Exception("T can only be of type: byte, sbyte, short, ushort, int, uint, long, ulong, float or double.");
            }

            getCount         = () => samples.Count;
            sampleIndexer    = i => samples[i];
            sampleEnumerator = samples.GetEnumerator();
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:IndexConnector" /> class.
        /// </summary>
        /// <param name="getWordFetcher">The GetWordFetcher delegate.</param>
        /// <param name="getSize">The GetSize delegate.</param>
        /// <param name="getCount">The GetCount delegate.</param>
        /// <param name="clearIndex">The ClearIndex delegate.</param>
        /// <param name="deleteData">The DeleteDataForDocument delegate.</param>
        /// <param name="saveData">The SaveData delegate.</param>
        /// <param name="tryFindWord">The TryFindWord delegate.</param>
        public IndexConnector(GetWordFetcher getWordFetcher, GetSize getSize, GetCount getCount, ClearIndex clearIndex,
            DeleteDataForDocument deleteData, SaveDataForDocument saveData, TryFindWord tryFindWord)
        {
            if(getWordFetcher == null) throw new ArgumentNullException("getWordFetcher");
            if(getSize == null) throw new ArgumentNullException("getSize");
            if(getCount == null) throw new ArgumentNullException("getCount");
            if(clearIndex == null) throw new ArgumentNullException("clearIndex");
            if(deleteData == null) throw new ArgumentNullException("deleteData");
            if(saveData == null) throw new ArgumentNullException("saveData");
            if(tryFindWord == null) throw new ArgumentNullException("tryFindWord");

            this.getWordFetcher = getWordFetcher;
            this.getSize = getSize;
            this.getCount = getCount;
            this.clearIndex = clearIndex;
            this.deleteData = deleteData;
            this.saveData = saveData;
            this.tryFindWord = tryFindWord;
        }
Example #13
0
        public static int IndexOf(BaseRedBlackTree <Node> tree, Node node, GetCount getCount)
        {
            if (node == null)
            {
                return(-1);
            }

            Debug.Assert(node.Root == node);
            int index = node.Left != null?getCount(node.Left) : 0;

            while (node.Parent != null)
            {
                if (node.Side)                 //if we're on the right side of a parent, add all the left sum
                {
                    index += getCount(node.Parent) - getCount(node);
                }

                node = node.Parent;
            }
            return(index);
        }
Example #14
0
        private void builderfunNew(string Method, string ApplicationStatus, string ApplicationNumber, string Reason)
        {
            UriBuilder builder = new UriBuilder();

            if (HttpContext.Current.Request.Url.Host.ToString() == "localhost")
            {
                builder = new UriBuilder("http://localhost:50369/api/ApplicationCount");
            }
            else
            {
                builder = new UriBuilder("https://aryavysya.karnataka.gov.in/api/ApplicationCount");
            }
            var query = HttpUtility.ParseQueryString(builder.Query);

            query["111111"] = "1111111111";
            if (Reason == "")
            {
                query["aaaaaaaa"] = "aaaaaaaa";
            }
            query["22222222"] = "2222222222";
            if (Reason == "11")
            {
                //builder.Query = "Status=" + Method + "&ApplicationStatus=" + ApplicationStatus + "&ApplicationNumber=" + ApplicationNumber + "&RejectReason=" + Reason;
                //builder.Query += Reason == "11" ? "&District" + Reason : "";
                query["bbbbbbbb"] = "bbbbbbbbbbb";
            }
            if (Reason == "2")
            {
                query["true"] = "true";
            }
            query["33333333"] = "33333333333";
            builder.Query     = query.ToString();
            Label1.Text       = builder.ToString() + "<br />" + builder.Query.ToString();

            GetCount          CwGetCount = new GetCount();
            AadhaarEnceyption AE         = new AadhaarEnceyption();

            Label1.Text += "<br />" + CwGetCount.GetTotalCount("spGetApplicationCount", Reason);
            Label1.Text += "<br />" + AE.GetAadhaarToken("301007056373");
        }
Example #15
0
        public Samples(IEnumerable <T> samples)
        {
            if (samples == null)
            {
                throw new ArgumentNullException("samples");
            }

            var inTypeName = typeof(T).FullName;

            if (!typeCheck.IsMatch(inTypeName))
            {
                throw new Exception("T can only be of type: byte, sbyte, short, ushort, int, uint, long, ulong, float or double.");
            }

            var count = 0;

            using (var enumerator = samples.GetEnumerator()) { while (enumerator.MoveNext())
                                                               {
                                                                   count++;
                                                               }
            }

            getCount      = () => count;
            sampleIndexer = i =>
            {
                var curInd = 0;
                foreach (var sam in samples)
                {
                    if (i == curInd)
                    {
                        return(sam);
                    }
                    curInd++;
                }

                throw new IndexOutOfRangeException();
            };
            sampleEnumerator = samples.GetEnumerator();
        }
Example #16
0
        public async void countProcess(bool isInQueue = false)
        {
            if (!HasKindOfProcess(Process.ProcessKind.COUNT_PROCESS))
            {
                var processId = _randomgen.Next();
                ProcessManagement(new Process {
                    ProcessID = processId, kind = Process.ProcessKind.COUNT_PROCESS
                });
                OnCountQueryStart(this, EventArgs.Empty);
                var    ok = true;
                string json;
                try
                {
                    var _client_count = new WebClient();
                    _client_count.Headers.Add("user-agent", "ehog BlitzInfo (.NET) - [email protected]");
                    PushToLog(this,
                              new BlitzEventArgs("Adatlekérés elindult", "Villám darabszám-grafikon",
                                                 BlitzEventArgs.EventMood.AWAIT));
                    json = await _client_count.DownloadStringTaskAsync($"{_restUrl}/stats/tenmin/48");

                    GetCount = StrokeTenmin.GetMultipleTenminDataFromJsonArray(json);
                    GetCount.Reverse();
                }
                catch (NotSupportedException exc)
                {
                    PushToLog(this,
                              new BlitzEventArgs("Kapcsolati hiba.", "Villám darabszám-grafikon",
                                                 BlitzEventArgs.EventMood.ERR));
                    ok = false;
                }

                catch (WebException exc)
                {
                    PushToLog(this,
                              new BlitzEventArgs("A kapcsolat megszakadt vagy nincs.", "Villám darabszám-grafikon",
                                                 BlitzEventArgs.EventMood.ERR));
                    ok = false;
                }
                finally
                {
                    if (GetCount.Count == 0)
                    {
                        PushToLog(this,
                                  new BlitzEventArgs(
                                      "A JSON nem tartalmaz elemeket. Talán frissül? Válaszd a villámok darabszáma fület, és nyomj F5-t, amíg nincs adat!",
                                      "Villám darabszám-grafikon", BlitzEventArgs.EventMood.ERR));
                        ok = false;
                    }

                    if (ok)
                    {
                        OnCountGot(this, EventArgs.Empty);
                        PushToLog(this,
                                  new BlitzEventArgs("Adatlekérés befejezve.", "Villám darabszám-grafikon",
                                                     BlitzEventArgs.EventMood.OK));
                    }

                    ProcessManagement(new Process {
                        ProcessID = processId, kind = Process.ProcessKind.COUNT_PROCESS
                    });
                }
            }
            else
            {
                if (!isInQueue)
                {
                    PushToLog(this,
                              new BlitzEventArgs(
                                  "A darabszám-grafikon adatainak lekérése már folyamatban, várakozási sorhoz adás...",
                                  "Villám darabszám-grafikon", BlitzEventArgs.EventMood.ERR));
                }
                addToQueue(Process.ProcessKind.COUNT_PROCESS);
            }
        }
 public FileSearcher(string dataPattern, int bufferSize, EndTest endTest, GetCount getCount, ReturnResult returnResult, GetFirstFileInfo getFirstFileInfo)
 {
     this.dataPattern = dataPattern.ToLower();
     this.bufferSize = bufferSize;
     this.endTest = endTest;
     this.getCount = getCount;
     this.returnResult = returnResult;
     this.getFirstFileInfo = getFirstFileInfo;
 }
Example #18
0
 public virtual string[] GetData()
 {
     string[] data = { GetName, GetPrice.ToString(), GetCount.ToString(), GetCost().ToString(), "" };
     return(data);
 }
Example #19
0
 public AddCounters(Func <Counter> counter, GetCount count)
 {
     _counterFactory = counter;
     _getCount       = count;
 }
 md = new MultiDownload(GetCount(e.ListURL.Count), e.ListURL);