Git Product home page Git Product logo

linkedpy's Introduction

linkedpy

linkedpy is a simple linked list implementation in Python, providing a custom List class with various methods for managing linked list operations.

Features

  • Basic Operations:

    • append(value): Add value to the end of the list.
    • insert(index, value): Insert a value before the specified index.
    • remove(value): Remove the first occurrence of a value.
    • pop(index=None): Remove and return an item at a specified index (default is the last item).
    • clear(): Remove all items from the list.
  • Access and Indexing:

    • __getitem__(index): Get the item at a specific index.
    • __setitem__(index, value): Set the item at a specific index.
    • __delitem__(index): Delete the item at a specific index.
  • Information and Iteration:

    • count(): Return the number of items in the list.
    • __len__(): Return the number of items in the list.
    • to_list(): Return the list as a normal Python list.
    • __repr__(): Return a string representation of the list.
    • __iter__(): Iterate over values in the list.
  • Concatenation:

    • __add__(other): Concatenate two lists using the + operator.
    • __iadd__(other): In-place concatenation using the += operator.
  • Statistical Operations:

    • min(): Return the minimum value in the list.
    • max(): Return the maximum value in the list.
  • Sorting:

    • sort(): Sort The list
    • sorted(): Return Sorted copy List

Usage

from linkedpy import List

# Create a new list
my_list = List(1, 2, 3)

# Append values
my_list.append(4)
my_list.append(5)

# Access elements
print(my_list[2])  # Output: 3

# Remove element
my_list.remove(2)

# Iterate over the list
for item in my_list:
    print(item)

# Concatenate lists
new_list = my_list + List(6, 7, 8)

# In-place concatenation
my_list += List(9, 10)

# Sorting

my_list.sort()

# Optional reverse argument
my_list.sorted(reverse=True)

linkedpy's People

Contributors

hardope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.