Git Product home page Git Product logo

golang-advanced-camp-language's Introduction

Sorted Linked List - Concurrent Safe 并发有序链表

GitHub code size in bytes

About It

This is a concurrent safe sorted linked list implemented by GO language. Its advantages are 1) It can limit the write operation to a specific area, and allow one write and multi reads within the area, as well as global concurrent read and write. 2) Read operation is implemented with a completely lockless structure which uses atomic for unrestricted access to nodes.

这是一个Go语言实现的并发有序链表,其优点是 1) 能够将写操作限制在某个区域,实现区域内的一写多读,全局并发读写。 2) 读操作采用了完全无锁的结构,使用atomic进行结点的无限制访问。

Usage

    // Return true if the list contains a node with specific value.
    // 检查一个元素是否存在,如果存在则返回 true,否则返回 false
    Contains(value int) bool
    
    // Return true if insert a new Node x into the list successfully.
    // 插入一个元素,如果此操作成功插入一个元素,则返回 true,否则返回 false
    Insert(value int) bool
    
    // Return true if delete the Node with specific value from the list successfully.
    // 删除一个元素,如果此操作成功删除一个元素,则返回 true,否则返回 false
    Delete(value int) bool
    
    // Traverse all nodes in the list and stop the traverse if function f returns false.
    // 遍历此有序链表的所有元素,如果 f 返回 false,则停止遍历
    Range(f func(value int) bool)

    // Return the length of the list.
    // 返回有序链表的元素个数
    Len() int

Test

  1. Run the Unit Test with command go test.

  2. Run the Concurrent Test with command go test -race.

More

skipset: A high-performance concurrent set based on skip list.
skipmap: A high-performance concurrent map based on skip list.
fastrand: Fastest pseudo-random number generator in Go.

Thanks

ByteDance TechAcademy, Golang Advanced Camp - Language Section in ByteDance, @zhangyunhao116

golang-advanced-camp-language's People

Watchers

James Cloos avatar Lindo Wu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.