• Interpretation of golang slice source code


    This paper studies the creation, expansion and deep copy implementation of golang slice from the source code perspective. Internal data structure Slice has only three fields, in which array is the part to save data, len field is length, and cap is capacity. type slice struct { array unsafe.Pointer //Data section Len int // length […]

  • Interviewer: “ready to use HashMap to store 1W pieces of data. Will 10000 pieces of data be transferred during construction, and will the expansion be triggered? “


    //It is estimated that 1W pieces of data will be saved, and the initial value will be 10000 to avoid resce. HashMap<String,String> map = new HashMap<>(10000) // for (int i = 0; i < 10000; i++) The expansion of Java collection HashMap is one of our most commonly used collections. Although for Android developers, Google […]

  • Java collection


      1. What’s the difference between list, set and map? List: ordered and repeatable elements Set: element cannot be duplicated Map: an element is a key value pair. The key uniquely identifies a key value pair. The key cannot be repeated. The element can be repeated. Both key and value can be of any type. […]

  • Dotnet source code learning – HashSet (initial exploration)


    Namespace: System.Collections.Generic Take a look at the official instructions:Class provides advanced setup operations.A set is a set that does not contain duplicate elements and has no specific order of elements。  HashSet The capacity of an object is the number of elements it can hold. When adding elements to an object, HashSetThe capacity of the object […]

  • Data structure and algorithm (implemented by golang) (13) common data structure variable length array


    Variable length array Because the array size is fixed, when there are many data elements, fixed arrays cannot store so many values, so variable length arrays appear, which is also a data structure. stayGolangIn language, variable length arrays are built into the language: slicingslice。 sliceIs the abstraction and control of the underlying array. It is […]

  • Lua resty limit traffic module provided by openresty


    [please indicate the source of reprint]: https://segmentfault.com/a/1190000022585978 Limit the total concurrent number of interfaces Scenario:Limit the number of concurrent connections according to IP lua_shared_dict my_limit_conn_store 100m; … location /hello { access_by_lua_block { local limit_conn = require “resty.limit.conn” –Limit one IP client to one concurrent request –Burst is set to 0. If the maximum number of […]

  • NGX of current limiting in access layer_ http_ limit_ req_ module


    [please indicate the source of reprint]: https://segmentfault.com/a/1190000022599606 ngx_ http_ limit_ req_ Module module is a request flow limiting module based on the leaky bucket algorithm provided by nginx, which is used to limit the flow of requests corresponding to the specified key, such as limiting the request rate according to the IP dimension. ngx_ http_ […]

  • Memory RAM capacity calculation


    Ram is also called random access memory, which is equivalent to the mobile storage on PC, mainly used to store and save data. It can read and write at any time. RAM memory is usually used as a temporary storage medium for operating system or other running programs. But when the power is off, RAM […]

  • Architecture design ideas


    Preface When we do architecture design, we usually go through three stages: requirement analysis, outline design and detailed design. Demand analysis stage: it mainly combs all use cases and scenarios, abstracts the users and roles of the system, and combs out which functional and non functional requirements the requirements provide to these users. General design […]

  • Over fitting and under fitting


    This article starts with the official account number: RAIS Preface This series of articles is the reading notes of deep learning, which can be read together with the original book for better effect. Building complex machine learning algorithm In the previous article, we introduced what is called machine learning algorithm and its specific definition and […]

  • Go arrays and slices


    1、 Definition of array //Var variable name [capacity of array] type = [capacity of array] type {value 1, value 2} var a [4]int = [4]int{1,2,3} perhaps var a = [4]int{1,2,3} perhaps a := [4]int{1,2,3} //These results are [1 23 0] //The accepted length is determined by the assigned length package main import “fmt” func main(){ […]

  • Principle learning of HashMap implementation


    Source code of HashMap: android-25 / Java / util / HashMap 1、 Construction method static final int MAXIMUM_CAPACITY = 1 << 30; static final int DEFAULT_INITIAL_CAPACITY = 4; static final float DEFAULT_LOAD_FACTOR = 0.75f; public HashMap() { this(DEFAULT_INITIAL_CAPACITY, DEFAULT_LOAD_FACTOR); } //Parameter default is 4,0.75f public HashMap(int initialCapacity, float loadFactor) { if (initialCapacity < 0) throw […]