Prepare 1.1.0 release (#1274)

* Update bucket_sort.c

* Fix the comments in quick_sort.c

* Update the announce badge

* Sync zh and zh-hant versions

* Update contributors list.

* Sync zh and zh-hant versions.

* Sync zh and zh-hant versions.

* Update the contributors list

* Update the version number
This commit is contained in:
Yudong Jin
2024-04-14 20:46:20 +08:00
committed by GitHub
parent 16942dfe32
commit d484b08c15
43 changed files with 471 additions and 115 deletions

View File

@ -6,11 +6,10 @@
package chapter_hashing
const val MODULUS = 1000000007
/* 加法雜湊 */
fun addHash(key: String): Int {
var hash = 0L
val MODULUS = 1000000007
for (c in key.toCharArray()) {
hash = (hash + c.code) % MODULUS
}
@ -20,6 +19,7 @@ fun addHash(key: String): Int {
/* 乘法雜湊 */
fun mulHash(key: String): Int {
var hash = 0L
val MODULUS = 1000000007
for (c in key.toCharArray()) {
hash = (31 * hash + c.code) % MODULUS
}
@ -29,6 +29,7 @@ fun mulHash(key: String): Int {
/* 互斥或雜湊 */
fun xorHash(key: String): Int {
var hash = 0
val MODULUS = 1000000007
for (c in key.toCharArray()) {
hash = hash xor c.code
}
@ -38,6 +39,7 @@ fun xorHash(key: String): Int {
/* 旋轉雜湊 */
fun rotHash(key: String): Int {
var hash = 0L
val MODULUS = 1000000007
for (c in key.toCharArray()) {
hash = ((hash shl 4) xor (hash shr 28) xor c.code.toLong()) % MODULUS
}