Go語言實現HashSet

set.go

// set project set.go
package settype Set interface {Add(e interface{}) boolRemove(e interface{})Clear()Contains(e interface{}) boolLen() intSame(other Set) boolElements() []interface{}String() string
}// 將集合other添加到集合one中
func AddSet(one Set, other Set) {if one == nil || other == nil || other.Len() == 0 {return}for _, v := range other.Elements() {one.Add(v)}
}// 判斷集合 one 是否是集合 other 的超集
func IsSuperset(one Set, other Set) bool {if one == nil || other == nil {return false}oneLen := one.Len()otherLen := other.Len()if oneLen == 0 || oneLen <= otherLen {return false}if oneLen > 0 && otherLen == 0 {return true}for _, v := range other.Elements() {if !one.Contains(v) {return false}}return true
}// 生成集合 one 和集合 other 的并集
func Union(one Set, other Set) Set {if one == nil && other == nil {return nil}unionedSet := NewSimpleSet()AddSet(unionedSet, one)AddSet(unionedSet, other)return unionedSet
}// 生成集合 one 和集合 other 的交集
func Intersect(one Set, other Set) Set {if one == nil || other == nil {return nil}intersectedSet := NewSimpleSet()if one.Len() == 0 || other.Len() == 0 {return intersectedSet}if one.Len() < other.Len() {for _, v := range one.Elements() {if other.Contains(v) {intersectedSet.Add(v)}}} else {for _, v := range other.Elements() {if one.Contains(v) {intersectedSet.Add(v)}}}return intersectedSet
}// 生成集合 one 對集合 other 的差集
func Difference(one Set, other Set) Set {if one == nil {return nil}differencedSet := NewSimpleSet()if other == nil || other.Len() == 0 {AddSet(differencedSet, one)return differencedSet}for _, v := range one.Elements() {if !other.Contains(v) {differencedSet.Add(v)}}return differencedSet
}// 生成集合 one 和集合 other 的對稱差集
func SymmetricDifference(one Set, other Set) Set {diffA := Difference(one, other)if other == nil || other.Len() == 0 {return diffA}diffB := Difference(other, one)return Union(diffA, diffB)
}// 返回一個HashSet
func NewSimpleSet() Set {return NewHashSet()
}// 判斷給定value是否為集合
func IsSet(value interface{}) bool {if _, ok := value.(Set); ok {return true}return false
}

hash_set.go

// hash_set
package setimport ("bytes""fmt"
)type HashSet struct {m map[interface{}]bool
}// 創建和初始化HashSet的方法
func NewHashSet() *HashSet {return &HashSet{m: make(map[interface{}]bool)}
}// 向HashSet中添加元素的方法
func (set *HashSet) Add(e interface{}) bool {if !set.m[e] {set.m[e] = truereturn true}return false
}// 刪除HashSet中指定的元素
func (set *HashSet) Remove(e interface{}) {delete(set.m, e)
}// 清除HashSet中的所有元素
func (set *HashSet) Clear() {set.m = make(map[interface{}]bool)
}// 判斷HashSet是否包含指定元素
func (set *HashSet) Contains(e interface{}) bool {return set.m[e]
}// 獲取HashSet中元素值數量
func (set *HashSet) Len() int {return len(set.m)
}// 判斷兩個Set類型值是否相同
func (set *HashSet) Same(other Set) bool {if other == nil {return false}if set.Len() != other.Len() {return false}for key := range set.m {if !other.Contains(key) {return false}}return true
}// 生成HashSet的一個快照
func (set *HashSet) Elements() []interface{} {initialLen := len(set.m)snapshot := make([]interface{}, initialLen)actualLen := 0for key := range set.m {if actualLen < initialLen {snapshot[actualLen] = key} else {snapshot = append(snapshot, key)}actualLen++}if actualLen < initialLen {snapshot = snapshot[:actualLen]}return snapshot
}// 獲取HashSet自身字符串表示形式
func (set *HashSet) String() string {var buf bytes.Bufferbuf.WriteString("Set{")first := truefor key := range set.m {if first {first = false} else {buf.WriteString(" ")}buf.WriteString(fmt.Sprintf("%v", key))}buf.WriteString("}")return buf.String()
}

功能測試:

set_test.go

// set_test
package setimport ("bytes""fmt""math/rand""runtime/debug""strings""testing""time"
)func testSetLenAndContains(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sLenAndContains...", typeName)set, expectedElemMap := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)expectedLen := len(expectedElemMap)if set.Len() != expectedLen {t.Errorf("ERROR: The length of %s value %d is not %d!\n",set.Len(), typeName, expectedLen)t.FailNow()}t.Logf("The length of %s value is %d.\n", typeName, set.Len())for k := range expectedElemMap {if !set.Contains(k) {t.Errorf("ERROR: The %s value %v do not contains %v!",set, typeName, k)t.FailNow()}}
}func testSetAdd(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sAdd...", typeName)set := newSet()var randElem interface{}var result boolexpectedElemMap := make(map[interface{}]bool)for i := 0; i < 5; i++ {randElem = genRandElement()t.Logf("Add %v to the %s value %v.\n", randElem, typeName, set)result = set.Add(randElem)if expectedElemMap[randElem] && result {t.Errorf("ERROR: The element adding (%v => %v) is successful but should be failing!\n",randElem, set)t.FailNow()}if !expectedElemMap[randElem] && !result {t.Errorf("ERROR: The element adding (%v => %v) is failing!\n",randElem, set)t.FailNow()}expectedElemMap[randElem] = true}t.Logf("The %s value: %v.", typeName, set)expectedLen := len(expectedElemMap)if set.Len() != expectedLen {t.Errorf("ERROR: The length of %s value %d is not %d!\n",set.Len(), typeName, expectedLen)t.FailNow()}t.Logf("The length of %s value is %d.\n", typeName, set.Len())for k := range expectedElemMap {if !set.Contains(k) {t.Errorf("ERROR: The %s value %v do not contains %v!",set, typeName, k)t.FailNow()}}
}func testSetRemove(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sRemove...", typeName)set, expectedElemMap := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)t.Logf("The length of %s value is %d.\n", typeName, set.Len())var number intfor k, _ := range expectedElemMap {if number%2 == 0 {t.Logf("Remove %v from the HashSet value %v.\n", k, set)set.Remove(k)if set.Contains(k) {t.Errorf("ERROR: The element removing (%v => %v) is failing!\n",k, set)t.FailNow()}delete(expectedElemMap, k)}number++}expectedLen := len(expectedElemMap)if set.Len() != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", set.Len(), expectedLen)t.FailNow()}t.Logf("The length of %s value is %d.\n", typeName, set.Len())for _, v := range set.Elements() {if !expectedElemMap[v] {t.Errorf("ERROR: The HashSet value %v contains %v but should not contains!", set, v)t.FailNow()}}
}func testSetClear(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sClear...", typeName)set, _ := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)t.Logf("The length of %s value is %d.\n", typeName, set.Len())t.Logf("Clear the HashSet value %v.\n", set)set.Clear()expectedLen := 0if set.Len() != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", set.Len(), expectedLen)t.FailNow()}t.Logf("The length of %s value is %d.\n", typeName, set.Len())
}func testSetElements(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sElements...", typeName)set, expectedElemMap := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)t.Logf("The length of %s value is %d.\n", typeName, set.Len())elems := set.Elements()t.Logf("The elements of %s value is %v.\n", typeName, elems)expectedLen := len(expectedElemMap)if len(elems) != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", len(elems), expectedLen)t.FailNow()}t.Logf("The length of elements is %d.\n", len(elems))for _, v := range elems {if !expectedElemMap[v] {t.Errorf("ERROR: The elements %v contains %v but should not contains!", set, v)t.FailNow()}}
}func testSetSame(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sSame...", typeName)set, _ := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)t.Logf("The length of %s value is %d.\n", typeName, set.Len())set2 := newSet()t.Logf("Clone the HashSet value %v...\n", set)for _, v := range set.Elements() {set2.Add(v)}result := set2.Same(set)if !result {t.Errorf("ERROR: Two sets are not same!")}t.Logf("Two sets are same.")
}func testSetString(t *testing.T, newSet func() Set, typeName string) {t.Logf("Starting Test%sString...", typeName)set, _ := genRandSet(newSet)t.Logf("Got a %s value: %v.", typeName, set)setStr := set.String()t.Logf("The string of %s value is %s.\n", typeName, setStr)var elemStr stringfor _, v := range set.Elements() {elemStr = fmt.Sprintf("%v", v)if !strings.Contains(setStr, elemStr) {t.Errorf("ERROR: The string of %s value %s do not contains %s!",typeName, setStr, elemStr)t.FailNow()}}
}// ----- Set 公用函數測試 -----

func TestIsSuperset(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestIsSuperset...")set, _ := genRandSet(func() Set { return NewSimpleSet() })set2 := NewSimpleSet()for _, v := range set.Elements() {set2.Add(v)}for extraElem := genRandElement(); ; {if set2.Add(extraElem) {break} else {time.Sleep(10 * time.Millisecond)}}if !IsSuperset(set2, set) {t.Errorf("ERROR: The HashSet value %v is not a superset of %v!\n", set2, set)t.FailNow()} else {t.Logf("The HashSet value %v is a superset of %v.\n", set2, set)}for extraElem := genRandElement(); ; {if set.Add(extraElem) {break} else {time.Sleep(10 * time.Millisecond)}}if IsSuperset(set2, set) {t.Errorf("ERROR: The HashSet value %v should not be a superset of %v!\n", set2, set)t.FailNow()} else {t.Logf("The HashSet value %v is not a superset of %v.\n", set2, set)}
}func TestUnion(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestUnion...")set, _ := genRandSet(func() Set { return NewSimpleSet() })t.Logf("The set value: %v", set)set2, _ := genRandSet(func() Set { return NewSimpleSet() })uSet := Union(set, set2)t.Logf("The set value (2): %v", set2)for _, v := range set.Elements() {if !uSet.Contains(v) {t.Errorf("ERROR: The union set value %v do not contains %v!",uSet, v)t.FailNow()}}for _, v := range set2.Elements() {if !uSet.Contains(v) {t.Errorf("ERROR: The union set value %v do not contains %v!",uSet, v)t.FailNow()}}t.Logf("The set value %v is a unioned set of %v and %v", uSet, set, set2)
}func TestIntersect(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestIntersect...")commonElem := genRandElement()set, _ := genRandSet(func() Set { return NewSimpleSet() })set.Add(commonElem)t.Logf("The set value: %v", set)set2, _ := genRandSet(func() Set { return NewSimpleSet() })set2.Add(commonElem)t.Logf("The set value (2): %v", set2)iSet := Intersect(set, set2)for _, v := range iSet.Elements() {if !set.Contains(v) {t.Errorf("ERROR: The set value %v do not contains %v!",set, v)t.FailNow()}if !set2.Contains(v) {t.Errorf("ERROR: The set value %v do not contains %v!",set2, v)t.FailNow()}}t.Logf("The set value %v is a intersected set of %v and %v", iSet, set, set2)
}func TestDifference(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestDifference...")commonElem := genRandElement()set, _ := genRandSet(func() Set { return NewSimpleSet() })set.Add(commonElem)t.Logf("The set value: %v", set)set2, _ := genRandSet(func() Set { return NewSimpleSet() })set2.Add(commonElem)t.Logf("The set value (2): %v", set2)dSet := Difference(set, set2)for _, v := range dSet.Elements() {if !set.Contains(v) {t.Errorf("ERROR: The set value %v do not contains %v!",set, v)t.FailNow()}if set2.Contains(v) {t.Errorf("ERROR: The set value %v contains %v!",set2, v)t.FailNow()}}t.Logf("The set value %v is a differenced set of %v to %v", dSet, set, set2)
}func TestSymmetricDifference(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestSymmetricDifference...")commonElem := genRandElement()set, _ := genRandSet(func() Set { return NewSimpleSet() })set.Add(commonElem)t.Logf("The set value: %v", set)set2, _ := genRandSet(func() Set { return NewSimpleSet() })set2.Add(commonElem)t.Logf("The set value (2): %v", set2)sdSet := SymmetricDifference(set, set2)for _, v := range sdSet.Elements() {if set.Contains(v) && set2.Contains(v) {t.Errorf("ERROR: The element %v can not be a common element of %v to %v!",v, set, set2)t.FailNow()}}t.Logf("The set value %v is a symmetric differenced set of %v to %v", sdSet, set, set2)
}// ----- 隨機測試對象生成函數 -----

func genRandSet(newSet func() Set) (set Set, elemMap map[interface{}]bool) {set = newSet()elemMap = make(map[interface{}]bool)var enough boolfor !enough {e := genRandElement()set.Add(e)elemMap[e] = trueif len(elemMap) >= 3 {enough = true}}return
}func genRandElement() interface{} {seed := rand.Int63n(10000)switch seed {case 0:return genRandInt()case 1:return genRandString()case 2:return struct {num int64str string}{genRandInt(), genRandString()}default:const length = 2arr := new([length]interface{})for i := 0; i < length; i++ {if i%2 == 0 {arr[i] = genRandInt()} else {arr[i] = genRandString()}}return *arr}
}func genRandString() string {var buff bytes.Buffervar prev stringvar curr stringfor i := 0; buff.Len() < 3; i++ {curr = string(genRandAZAscii())if curr == prev {continue} else {prev = curr}buff.WriteString(curr)}return buff.String()
}func genRandAZAscii() int {min := 65 // Amax := 90 // Z
    rand.Seed(time.Now().UnixNano())return min + rand.Intn(max-min)
}func genRandInt() int64 {return rand.Int63n(10000)
}

hash_set_test.go

// hash_set_test
package setimport ("fmt""runtime/debug""strings""testing"
)func TestHashSetCreation(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()t.Log("Starting TestHashSetCreation...")hs := NewHashSet()t.Logf("Create a HashSet value: %v\n", hs)if hs == nil {t.Errorf("The result of func NewHashSet is nil!\n")}isSet := IsSet(hs)if !isSet {t.Errorf("The value of HashSet is not Set!\n")} else {t.Logf("The HashSet value is a Set.\n")}
}func TestHashSetLenAndContains(t *testing.T) {testSetLenAndContains(t, func() Set { return NewHashSet() }, "HashSet")
}func TestHashSetAdd(t *testing.T) {testSetAdd(t, func() Set { return NewHashSet() }, "HashSet")
}func TestHashSetRemove(t *testing.T) {testSetRemove(t, func() Set { return NewHashSet() }, "HashSet")
}func TestHashSetClear(t *testing.T) {testSetClear(t, func() Set { return NewHashSet() }, "HashSet")
}func TestHashSetElements(t *testing.T) {testSetElements(t, func() Set { return NewHashSet() }, "HashSet")
}func TestHashSetSame(t *testing.T) {testSetSame(t, func() Set { return NewHashSet() }, "HashSet")
}func TestSetString(t *testing.T) {testSetString(t, func() Set { return NewHashSet() }, "HashSet")
}func testSetOp(t *testing.T) {defer func() {if err := recover(); err != nil {debug.PrintStack()t.Errorf("Fatal Error: %s\n", err)}}()fmt.Println(222)t.Logf("Starting TestHashSetOp...")hs := NewHashSet()if hs.Len() != 0 {t.Errorf("ERROR: The length of original HashSet value is not 0!\n")t.FailNow()}randElem := genRandElement()expectedElemMap := make(map[interface{}]bool)t.Logf("Add %v to the HashSet value %v.\n", randElem, hs)hs.Add(randElem)expectedElemMap[randElem] = trueexpectedLen := len(expectedElemMap)if hs.Len() != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", hs.Len(), expectedLen)t.FailNow()}var result boolfor i := 0; i < 8; i++ {randElem = genRandElement()t.Logf("Add %v to the HashSet value %v.\n", randElem, hs)result = hs.Add(randElem)if expectedElemMap[randElem] && result {t.Errorf("ERROR: The element adding (%v => %v) is successful but should be failing!\n",randElem, hs)t.FailNow()}if !expectedElemMap[randElem] && !result {t.Errorf("ERROR: The element adding (%v => %v) is failing!\n",randElem, hs)t.FailNow()}expectedElemMap[randElem] = true}expectedLen = len(expectedElemMap)if hs.Len() != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", hs.Len(), expectedLen)t.FailNow()}for k, _ := range expectedElemMap {if !hs.Contains(k) {t.Errorf("ERROR: The HashSet value %v do not contains %v!", hs, k)t.FailNow()}}number := 2for k, _ := range expectedElemMap {if number%2 == 0 {t.Logf("Remove %v from the HashSet value %v.\n", k, hs)hs.Remove(k)if hs.Contains(k) {t.Errorf("ERROR: The element adding (%v => %v) is failing!\n",randElem, hs)t.FailNow()}delete(expectedElemMap, k)}number++}expectedLen = len(expectedElemMap)if hs.Len() != expectedLen {t.Errorf("ERROR: The length of HashSet value %d is not %d!\n", hs.Len(), expectedLen)t.FailNow()}for _, v := range hs.Elements() {if !expectedElemMap[v] {t.Errorf("ERROR: The HashSet value %v contains %v!", hs, v)t.FailNow()}}hs2 := NewHashSet()for k, _ := range expectedElemMap {hs2.Add(k)}if !hs.Same(hs2) {t.Errorf("ERROR: HashSet value %v do not same %v!\n", hs, hs2)t.FailNow()}str := hs.String()t.Logf("The string of HashSet value %v is '%s'.\n", hs, str)for _, v := range hs.Elements() {if !strings.Contains(str, fmt.Sprintf("%v", v)) {t.Errorf("ERROR: '%s' do not contains '%v'!", str, v)t.FailNow()}}
}

?

轉載于:https://www.cnblogs.com/gaopeng527/p/6154977.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/394428.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/394428.shtml
英文地址,請注明出處:http://en.pswp.cn/news/394428.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

c#控件彈幕效果_C# Form 實現桌面彈幕

使用C# Form 簡單的實現了彈幕效果1.創建一個Form 設置2.添加一個計時器3. 代碼using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Drawing.Text;using System.Linq;using System.Text;using S…

Makefile中怎么使用Shell if判斷

/********************************************************************** Makefile中怎么使用Shell if判斷* 說明&#xff1a;* 譬如可能會在Makfile中需要判斷文件、文件夾的存在&#xff0c;使用shell語法* 輸出一些信息&#xff0c;等等。** …

我如何使用React和Typescript在freeCodeCamp中構建天氣應用

by Kelvin Mai通過凱文麥 我如何使用React和Typescript在freeCodeCamp中構建天氣應用 (How I built the weather app in freeCodeCamp using React and Typescript) So I finally decided to come back to freeCodeCamp and try to finish out my Front End Development Certi…

mysql結果集相減_MySQL_(Java)使用JDBC向數據庫發起查詢請求

課程相關鏈接&#xff1a;JDBC編程和MySQL數據庫課程源代碼在文章末尾~Java Database Connectivity簡單來說就是使用Java里面提供的一些類和方法&#xff0c;利用程序鏈接數據庫&#xff0c;進行增刪改查操作。這個過程就叫做JDBC編程接下來我們便分五步通過JDBC對MySQL中的數據…

在雙系統(Windows與Ubuntu)下刪除Ubuntu啟動項

問題概述&#xff1a;因為在自己學習Linux的時候&#xff0c;按照網上的教程錯誤的刪除了Ubuntu的一個內核驅動&#xff0c;導致Ubuntu不能啟動。我想到的辦法是重新安裝系統&#xff0c;重裝系統的第一步便是將Ubuntu從電腦中卸載。該筆記是有關如何刪除Ubuntu啟動項的。 使用…

iangularjs 模板_2018-web前端的自我介紹-優秀word范文 (5頁)

本文部分內容來自網絡整理&#xff0c;本司不為其真實性負責&#xff0c;如有異議或侵權請及時聯系&#xff0c;本司將立即刪除&#xff01;本文為word格式&#xff0c;下載后可方便編輯和修改&#xff01;web前端的自我介紹篇一&#xff1a;個人總結的web前端面試題1、自我介紹…

Teradata QueryGrid整合最佳分析技術 拓展客戶選擇空間

ZDNET至頂網CIO與應用頻道 05月11日 北京消息&#xff1a; 為持續幫助企業克服數據散布在不同分析系統的困難&#xff0c;全球領先的大數據分析和營銷應用服務供應商Teradata天睿公司宣布對Teradata QueryGrid 進行重要技術升級。此次升級新增并強化六項QueryGrid技術&#xf…

神舟筆記本bios_海爾雷神(藍天)神舟戰神游戲本風扇狂轉掉電大寫燈狂閃維修實例...

昨天收到一臺網友寄過來的海爾雷神游戲本。說到這個游戲本品牌&#xff0c;其實有幾個品牌的筆記本&#xff0c;它們的主板和模具是一模一樣的&#xff0c;也就是我們看到的品牌log不一樣而已。比如神舟的戰神 &#xff0c;機械師&#xff0c;機械革命&#xff0c;麥本本等等。…

Oracle 學習----:查看當前時間與Sqlserver語句不一樣了

oracle:select sysdate from dual sqlserver: select getdate() ---------------------試試這個---------------------------------------------------------- insert into OracleTab values(sysdate) insert into SqlserverTab values(getdate())轉載于:https://www.cnblogs…

react發送和接收請求_React行為編程簡介:請求,等待和阻止

react發送和接收請求by Luca Matteis盧卡馬蒂斯(Luca Matteis) React行為編程簡介&#xff1a;請求&#xff0c;等待和阻止 (An intro to Behavioral Programming with React: request, wait, and block) Behavioral Programming (BP) is a paradigm coined in the 2012 artic…

leetcode96. 不同的二叉搜索樹(動態規劃)

給定一個整數 n&#xff0c;求以 1 … n 為節點組成的二叉搜索樹有多少種&#xff1f; 解題思路 *數組含義&#xff1a;dp[i] i個節點的不同組成結構 狀態轉移&#xff1a;任取節點為根節點&#xff0c;遍歷左右子樹可能出現的個數,dp[i]dp[left]dp[right] 初始化&#xff1a…

“康園圈--互聯網+校園平臺“項目之成果展示及項目總結

一、總體效果&#xff08;ipad端截圖&#xff09; 網站前臺頁面網站后臺管理臺頁面二、前臺訪問鏈接&#xff08;用pc訪問效果最佳&#xff09;&#xff1a;http://www.liangzhilin.cn:9100/kangyuanquan/ &#xff08;為保證數據安全&#xff0c;后臺管理鏈接不對外公開&#…

ajax jq 圖片上傳請求頭_Jquery ajaxsubmit上傳圖片實現代碼

這是數月前的事情了&#xff0c;場景是這樣的&#xff1a; 在進行圖片上傳的時&#xff0c;我發現開發人員使用的上傳圖片方式是Iframe 傳統的 http post 來處理的。而且未建立統一上傳函數。于是將代碼改造了。心想來個ajax異步上傳圖片吧&#xff0c;這技術應該很老套了。于…

這個免費的交互式課程在一小時內學習JavaScript

JavaScript is the most popular programming language on the web. You can use it to create websites, servers, games and even native apps. So no wonder it’s such a valuable skill in today’s job market.JavaScript是網絡上最流行的編程語言。 您可以使用它來創建網…

java中二進制怎么說_面試:說說Java中的 volatile 關鍵詞?

volatile 這個關鍵字可能很多朋友都聽說過&#xff0c;或許也都用過。在 Java 5 之前&#xff0c;它是一個備受爭議的關鍵字&#xff0c;因為在程序中使用它往往會導致出人意料的結果。在 Java 5之后&#xff0c;volatile 關鍵字才得以重獲生機。volatile 關鍵字雖然從字面上理…

類的詳解

面向對象是一種編程方式&#xff0c;此編程方式的實現是基于對類和對象的使用。類是一個模板&#xff0c;模板中包裝了多個“函數”供使用&#xff08;可以講多函數中公用的變量封裝到對象中&#xff09;。對象&#xff0c;根據模板創建的實例&#xff08;即對象&#xff09;&a…

leetcode279. 完全平方數(動態規劃)

給定正整數 n&#xff0c;找到若干個完全平方數&#xff08;比如 1, 4, 9, 16, …&#xff09;使得它們的和等于 n。你需要讓組成和的完全平方數的個數最少。 示例 1: 輸入: n 12 輸出: 3 解釋: 12 4 4 4. 解題思路 數組含義&#xff1a;dp[i]數字i對應組成和的完全平方…

什么情況不能辦理房產抵押貸款 房產抵押貸能貸多少?

所謂房產抵押貸款是指以自己或親友的房產作為抵押物向貸款機構申請貸款&#xff0c;款項可用于企業經營、買房、買車、裝修及其他用途的融資方式。但是有些情況是規定不能申請房產抵押貸款的&#xff0c;而且貸款的數額是有限的&#xff0c;不是想貸多少就多少。那么&#xff0…

Android RecyclerView 二級列表實現

Android RecyclerView 二級列表實現

2數據庫表增加一個字段_14個實用的數據庫設計技巧!

1. 原始單據與實體之間的關系可以是一對一、一對多、多對多的關系。在一般情況下&#xff0c;它們是一對一的關系&#xff1a;即一張原始單據對應且只對應一個實體。在特殊情況下&#xff0c;它們可能是一對多或多對一的關系&#xff0c;即一張原始單證對應多個實體&#xff0c…