linked-list-good-taste | Linus Torvalds' linked list argument for good taste, explained

 by   mkirchner C Version: Current License: MIT

kandi X-RAY | linked-list-good-taste Summary

kandi X-RAY | linked-list-good-taste Summary

linked-list-good-taste is a C library. linked-list-good-taste has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

In a 2016 TED interview (14:10) Linus Torvalds speaks about what he considers good taste in coding. As an example, he presents two implementations of item removal in singly linked lists (reproduced below). In order to remove the first item from a list, one of the implementations requires a special case, the other one does not. Linus, obviously, prefers the latter. [...] I don't want you to understand why it doesn't have the if statement. But I want you to understand that sometimes you can see a problem in a different way and rewrite it so that a special case goes away and becomes the normal case, and that's good code. [...] -- L. Torvalds. The code snippets he presents are C-style pseudocode and are simple enough to follow. However, as Linus mentions in the comment, the snippets lack a conceptual explanation and it is not immediately evident how the more elegant solution actually works. The next two sections look at the technical approach in detail and demonstrate how and why the indirect addressing approach is so neat. The last section extends the solution from item deletion to insertion.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              linked-list-good-taste has a medium active ecosystem.
              It has 1796 star(s) with 105 fork(s). There are 21 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 0 open issues and 10 have been closed. On average issues are closed in 122 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of linked-list-good-taste is current.

            kandi-Quality Quality

              linked-list-good-taste has no bugs reported.

            kandi-Security Security

              linked-list-good-taste has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              linked-list-good-taste is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              linked-list-good-taste releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of linked-list-good-taste
            Get all kandi verified functions for this library.

            linked-list-good-taste Key Features

            No Key Features are available at this moment for linked-list-good-taste.

            linked-list-good-taste Examples and Code Snippets

            No Code Snippets are available at this moment for linked-list-good-taste.

            Community Discussions

            Trending Discussions on linked-list-good-taste

            QUESTION

            How could I get address of the target object in smart pointer?
            Asked 2021-Dec-26 at 19:47

            I'm trying to implement the linked list by indirect pointer, which introduced on the TED Talk.

            I refer to felipec's implementation on github and made an version by raw pointer, this is the github link.

            This is part of the full code, _find is a function that can find the indirect pointer of target node, which means *indirect == target node :

            ...

            ANSWER

            Answered 2021-Dec-26 at 19:47

            How could I get the address of the target object in smart pointer?

            I think you mean "the address of the pointer in the smart pointer", because the address of the target object is just what you get with .get(). std::unique_ptr does not offer any interface to access it's pointer member directly, so it is impossible.

            Did I use the smart pointer in correct way? Should I change shared_ptr to unique_ptr, or just not use smart pointer for it?

            Using std::unique_ptr is the correct thing to do. You don't need shared_ptr because there are never two owners of any given node.

            In your first code indirect is a pointer to a raw pointer in the Node/List structure. Since you changed these to smart pointers, indirect should also become a pointer to a smart pointer:

            Source https://stackoverflow.com/questions/70489196

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install linked-list-good-taste

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mkirchner/linked-list-good-taste.git

          • CLI

            gh repo clone mkirchner/linked-list-good-taste

          • sshUrl

            git@github.com:mkirchner/linked-list-good-taste.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link