Skip to main content

This package contains implementation of the library "InfiniteList". InfiniteList is a data type supporting lists of any lengths by using class attributes storing small sublists.

Project description

InfiniteList

InfiniteList is a data type which can support any number of elements. This can be done by using class attributes storing a low number of elements.

Installation

pip install InfiniteList

Usage

To use this library, install it using the command shown in "Installation" section. Then, read the instructions below regarding how to use operations with InfiniteList.

count()

InfiniteList class has 'count()' method accepting an element as the parameter to get the number of occurrences of an element in the list.

For example: a: InfiniteList = InfiniteList([2, 3, 4, 3]) a.count(3) -> returns 2

copy()

InfiniteList has 'copy()' method to return a copy of itself.

index()

InfiniteList class has 'count()' method accepting an element as the parameter to get the index of the first occurrence of that element in the list.

For example: a: InfiniteList = InfiniteList([2, 3, 4, 3]) a.index(3) -> returns 1

reverse()

'reverse()' method in InfiniteList class reverses the order of elements in the list.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c.reverse() print(c) -> prints [6, 5, 3, 4]

sort()

'sort()' method in InfiniteList class sorts all its elements in ascending order.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c.sort() print(c) -> prints [3, 4, 5, 6]

min()

'min()' method in InfiniteList returns the minimum element in the list.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(c.min()) -> prints 3

max()

'max()' method in InfiniteList returns the maximum element in the list.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(c.max()) -> prints 6

sum()

'sum()' method in InfiniteList returns the sum of elements in the list.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(c.sum()) -> prints 18

extend()

InfiniteList class has 'extend()' method which adds all elements from a list or iterable to the InfiniteList. The elements are added to the end of the InfiniteList.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c.extend([7, 8]) print(c) -> prints [4, 3, 5, 6, 7, 8]

insert()

'insert()' method in InfiniteList inserts an element at a particular index in the list.

For example: c: InfiniteList = InfiniteList([1, 2, 3]) c.insert(1, 4) print(c) -> prints [1, 4, 2, 3]

append()

'append()' method in InfiniteList adds an element to the end of the list.

For example: c: InfiniteList = InfiniteList([1, 2, 3]) c.append(5) print(c) -> prints [1, 2, 3, 5]

delete()

'delete()' method in InfiniteList removes an element at a particular index in the list.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c.delete(1) print(c) -> prints [4, 5, 6]

remove()

'remove()' method in InfiniteList removes an elements in the list if it exists.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c.remove(5) print(c) -> prints [4, 3, 6]

clear()

'clear()' method in InfiniteList removes all elements from the list.

length

To get the number of elements in an InfiniteList, you can write a code in the format 'len(infinite_list)'.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(len(c)) -> prints 4

get an item

To get an item from an InfiniteList, you can write a code in the format 'infinite_list[index]'.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(c[2]) -> prints 5

edit an item in the list

To edit the value of an item in the list, you need to specify the index of the item you want to edit and the new value of the item.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) c[2] = 7 print(c) -> prints [4, 3, 7, 6]

str

Using Python's built-in 'print' function followed with an InfiniteList will print out all the elements in the InfiniteList.

For example: c: InfiniteList = InfiniteList([4, 3, 5, 6]) print(c) -> prints [4, 3, 5, 6]

Running Tests

The script "BigNumber_versus_mpf.py" (https://github.com/GlobalCreativeCommunityFounder/InfiniteList/blob/main/InfiniteList/InfiniteList_versus_list.py) is used to run tests of the performance of InfiniteList library against Python's built-in list class.

Sample Test Results

Examples of test results for InfiniteList versus list are in the following files:

  1. https://github.com/GlobalCreativeCommunityFounder/InfiniteList/blob/main/InfiniteList/InfiniteList_versus_list_append.txt (testing for performance of adding items to lists)
  2. https://github.com/GlobalCreativeCommunityFounder/InfiniteList/blob/main/InfiniteList/InfiniteList_versus_list_sort.txt (testing for performance of sorting items in lists)

Project details


Release history Release notifications | RSS feed

This version

1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

InfiniteList-1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

InfiniteList-1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file InfiniteList-1.tar.gz.

File metadata

  • Download URL: InfiniteList-1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for InfiniteList-1.tar.gz
Algorithm Hash digest
SHA256 49313349c24f4d38e712f235cbd1cc2c2bb063c6e3e9305168f2c3910e87f437
MD5 577b381ef0efe668bc08d424f9c49132
BLAKE2b-256 8b0820684357f2318e2a53d7213ac7d344ff532d8d4acf64d63bfc0d86521254

See more details on using hashes here.

File details

Details for the file InfiniteList-1-py3-none-any.whl.

File metadata

  • Download URL: InfiniteList-1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for InfiniteList-1-py3-none-any.whl
Algorithm Hash digest
SHA256 f94d03f244f78bbfe0d4a270c35084fe1e4ddf0a516e94baa5482635306544b4
MD5 702225b2da412580158742d7fd3e448f
BLAKE2b-256 384267a41122ff40bc424bd29ecac027a0c13f3e1ba61c19c427f4b41107c75b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page