C#, C# source program of Google CityHash64 and CityHash128 hashing algorithms

1. A brief history of CityHash Google released the CityHash series of string hashing algorithms in 2011. There are two algorithms released today: CityHash64 and CityHash128. They calculate 64- and 128-bit hashes respectively from the string. These algorithms are not suitable for encryption, but are suitable for use in hash tables, etc. Google has been optimizing the algorithm based on the CPUs commonly used in its data centers and found that it is equally effective for most personal computers and laptops. Especially in terms of 64-bit registers, instruction set-level parallelism, and fast non-paired memory accesses. The development of this algorithm was greatly inspired by previous work on hashing algorithms, especially Austin Appleby’s MurmurHash. But the main advantage of CityHash is that most steps contain at least two separate mathematical operations. Modern CPUs usually get the best performance from this kind of code. But CityHash also has its disadvantages: the code is more complex than similar popular algorithms. Google wants to optimize for speed rather than simplicity, so it doesn’t take care of the special case of shorter inputs. In general, CityHash64 and CityHash128 are new algorithms that solve classic problems. In practical applications, Google expects CityHash64 to be at least…

go_[“a”,”a”,”b”,”b”,”c”,”c”,”c&quot

443. Compressed string // jsJSON. parse() methodJSON.stringify() method // javaint[][] ghosts = JSON.parseObject(cin.nextLine(), int[][].class);// goif errJson2 := json.Unmarshal([]byte(targetInput), &target); errJson2 != nil { println(“errJson2:”, errJson2) return } // pythonjson.loads() methodjson.json() method Gives you a character array chars, please use the following algorithm for compression: Start with an empty string s. For each group of consecutively repeated characters in chars: If the group has length 1, append the characters to s. Otherwise, characters need to be appended to s, followed by the length of the group. The compressed string s should not be returned directly, but needs to be dumped into the character array chars. It should be noted that if the group length is 10 or more, it will be split into multiple characters in the chars array. After modifying the input array, please return the new length of the array. You must design and implement an algorithm that uses only constant extra space to solve this problem. Example 1: Input: chars = [“a”,”a”,”b”,”b”,”c”,” c”,”c”]Output: Return 6, the first 6 characters of the input array should be: [“a”,”2″,”b”,”2″,”c”,”3″ ]Explanation:“aa” is replaced by “a2”. “bb” is replaced by “b2”. “ccc” is replaced by “c3”. Example 2: Input: chars = [“a”]Output: Return…

An article to help you understand the analysis of parameter passing principles (java, go, python, c++)

An article to help you understand the analysis of parameter passing principles (java, go, python, c++)

Foreword In the past year or so, I have been exposed to some languages ​​that are unfamiliar to me, mainly Python and Go. During this period, in order to quickly realize the needs, I just followed the example. Lao’s code; I didn’t delve into some details and principles. Take parameter passing as an example. The implementation details of each language are different, but there are similarities; it is easy for many novices to be confused when they get started, leading to some low-level mistakes. Java Basic type transfer Let’s take Java, which I am most familiar with, as an example. I believe no one can write such code: @Test public void testBasic() { int a = 10; modifyBasic(a); System.out.println(String.format(“Final result main a==%s”, a)); } private void modifyBasic(int aa) { System.out.println(String.format(“aa==%s”, aa)); aa = 20; System.out.println(String.format(“After modification aa==%s”, aa)); } Output results: Before modification aa==10 After modification aa==20 Final result main a==10 However, judging from the purpose of this code, it should be to modify the value of a. Intuitively, it is understandable if the modification is successful. The fundamental reason why the results are not in line with expectations is the misunderstanding of parameter value passing and reference passing. Before…

C, C++, Java to Python, which language is better to learn for beginners of programming?

Abstract: Looking back at the rise and fall of programming languages ​​over the past few decades, it seems to reflect the changes and demise of the entire information industry. If you want to advance bravely in the torrent of technology, it is even more important to find and master one or two programming languages. It’s important. Recently, TIOBE updated its programming language list for July. C, Java and Python, which have always dominated the list, still remain in the top three. What I never expected was that the R language actually rushed to eighth place, setting the best record in history. And with the subsequent increase in demand for data statistics and mining in the industry, the popularity of R language is quite unstoppable. However, as a tool for programmers to eat, programming languages ​​have also formed a certain chain of contempt. There is an atmosphere of tension in the major forums, and it is difficult to reconcile the opinions. It’s no wonder that many beginners have doubts, why are there so many programming languages, and which language should I learn? Looking back at the rise and fall of programming languages ​​over the past few decades, it seems to reflect…

Implementation of mutual conversion between emoji expressions and unicode encoding (JS, JAVA, C#)

A few days ago, there was a need to convert the Unicode encoding corresponding to emoji into text, such as the “smiley face” corresponding to 1f601, but I did not find a C# method to convert 1f601 into text. How to convert using Encoding.Unicode None of them are right. In the end, I copied the emoji characters directly, and they were displayed directly in Visual Studio. Then just use the characters without converting them, and then let it go. Today I was working on the Markdown editor. Due to the GFM issue earlier, I also tested the encoding. I didn’t find any reliable information. I found a lot of emoji and Unicode comparison tables, https://apps.timwhitlock.info/emoji /tables/unicode Take a smiley face https://apps.timwhitlock.info/unicode/inspect/hex/1F601 for surgery~ 1. Convert emoticon characters to encoding 【C#】 Encoding.UTF32.GetBytes(“😁”) -> [“1”, “f6”, “1”, “0”] 【js】 “😁”.codePointAt(0).toString(16) -> 1f601 【java】 byte[] bytes = “😀”.getBytes(“utf-32”); System.out.println(getBytesCode(bytes)); private static String getBytesCode(byte[] bytes) { String code = “”; for (byte b : bytes) { code += “\\x” + Integer.toHexString(b & 0xff); } return code; } UTF-32 results are consistent 【C#】 Encoding.UTF8.GetBytes(“😁”) -> [“f0”, “9f”, “98”, “81”] 【js】 encodeURIComponent(“😁”) -> %F0%9F%98%81 UTF-8 results are consistent 2. Encoding to emoticon characters 【js】 String.fromCodePoint(‘0x1f601’) utf-32…

Push

[Data structure] stack (stack) stack chain (animated diagram, c++, java)

Article directory Overview of stack chain(Illustration) Basic operations of chain stack 1. Initialization 2. Push to the stack 3. Pop from the stack 4. Get the top of the stack 9. Complete code Summary The following is the text of this article,The following case Available for reference. Stack chain overview(Illustration) The stack can be stored sequentially,or chained,called sequential stack and chain respectively Stack. The sequential stack allocates a continuous space,It requires two pointers,base points to the bottom of the stack,top points to the top of the stack. The address of each node in the chain stack is discontinuous, only one stack top pointer is needed. From the figure, you can It can be seen that each node of the chain stack contains two fields:data domain and pointer domain font>. Basic operations of the chain stack The chain stack can be regarded as a singly linked list without a head node,But it can only be inserted at the head Operations such as , deletion, and value retrieval cannot be performed in the middle or at the end. Therefore, the nodes of the chain stack can be defined in the singly linked list method. First define a structure. xff08;The inner class), contains…

Share: C language Chinese word segmentation service, with a vocabulary of more than 1.9 million words, segmentation of more than 50,000 per second, and providing c, java, C#, delphi, and js calling examples

Share: C language Chinese word segmentation service, with a vocabulary of more than 1.9 million words, segmentation of more than 50,000 per second, and providing c, java, C#, delphi, and js calling examples

Share: C language Chinese word segmentation service, with a vocabulary of more than 1.9 million words, segmentation of more than 50,000 per second, and providing c, java, C#, delphi, and js calling examples The version 3.0 algorithm has been comprehensively revised, and word segmentation accuracy, service stability, robustness, and speed have all made a qualitative leap! Also provides c, java, C#, delphi, js calling examples Development language: C languageCompiler: GCCTest environment: xp, win2000, win2003, win7, win2008, win8Quality test: A total of 3,000 random articles of 10K+ in the use caseAverage performance: Articles within 50,000 words can be divided into single threads in 1 second Split completed Supports large-scale concurrency, thread safety, and articles within 50,000 words can be divided into single threads within 1 second! Software name: Million Business Circle Chinese Word Segmentation Server Author: QQ 99923309 When used specifically, you can Thesaurus file (more than 1.9 million words) bwsyq.com.dat can be placed in the same directory as the word segmentation server Please start the word segmentation server before using it The word segmentation server program is A windows service program, the service name is: bwsyq fenci service and serve 0.1 (Millions of Business Circle Chinese Word Segmentation Server) At…

Configure gedit as the strongest compilation tool (C, C++, Java) - article picture

Configure gedit as the most powerful compilation tool (C, C++, Java)

Enter root mode 1 sudo -i Open gedit 1 gedit &# 160; In the preferences, you can choose the color theme, line number, etc. of the text editor Please complete this operation before proceeding to the next step   dconf-editor Enter the last item of the terminal in plugins, cancel use-them-colors, if gedit is not installed -plugins Execute sudo apt-get install gedit-plugins   Then we proceed to the next step, Write Sell to compile and run the code in gedit   Click on the external management tool   Only this content, let’s click the plus sign in the lower left corner Create the first tool: Compile #The name can be arbitrary   #!/bin/shfullname=$GEDIT_CURRENT_DOCUMENT_NAMEname=`echo $fullname | cut -d. -f1` suffix=`echo $fullname | cut -d. -f2`if [ $suffix = “c” ]; then gcc $fullname -o $name -O2 -Wall -std=gnu99 -static -lm elif [ $suffix = “cpp” ] || [ $suffix = “c++” ] || [ $suffix = “cc” ] || [ $suffix = “cxx” ] || [ $suffix = “C ” ]; then g++ $fullname -o $name -O2 -Wall -std=gnu++0x -static -lmelif [ $suffix = “java” ]; then javac $fullname – encoding UTF-8 -sourcepath . -d .fi View Code   Copy these…

Look at performance optimization from several performance test cases in three languages ​​(C++, Java, C#)

With the development of time, the current virtual machine technology is becoming more and more mature. In some cases, the performance of intensive computing of virtual machines such as Java and .Net is similar to that of C++. In some cases, it is even better. excellent. This article analyzes several performance test cases in detail and explores the reasons behind the phenomenon. Let’s look at two simple test cases. As shown in the figure below, they all loop 5000 times, operate the continuous memory of len = 1000000, and calculate the execution time. The left side is test1 and the right side is test2. Similar programs were tested under .net core 3.0 Preview6. The test results are compared as follows: We can see that for test1, the C++ version is much faster. For test2, the performance of the C# version and the C++ version are equivalent, or even slightly faster. Why does this happen? Let’s analyze it in detail: The assignment of the loop of test1 is position-independent, so the compiler can optimize it through parallel computing instructions such as SIMD. The assignment of the loop of test2 is position-related, and it is difficult for the compiler to optimize using…

Python, C, Java and C++ stand on top of each other, and the others have no chance of winning?

Python, C, Java and C++ stand on top of each other, and the others have no chance of winning?

Organization | Su Mi Produced by | CSDN The ever-changing nature of technology can be traced. The latest TIOBE October programming language list has been released. Come and see what changes are worth paying attention to! 01 The four major programming languages ​​continue to increase their dominance Once upon a time, the iron triangle composed of Java, C, and C++ in the programming language world has been stable for a long time. Just a year ago, Python surpassed the C language and broke the TIOBE list for more than 20 years. It topped the list for the first time and completely broke the original iron triangle structure. Since then, Python has been making rapid progress. Now, according to the latest October list, TIOBE officials pointed out that Python, C, Java and C++ have been on the TIOBE index list for a long time. The Top 4 languages ​​alone are far ahead of the rest, and the gap seems to be growing. For example, C++, which ranks fourth this month, accounts for 9.92%, which is 5.5% higher than C#, which accounts for 4.42% and ranks fifth. In addition, in the last year, these four languages The cumulative market share is 40%,…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索