Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array opperations #19

Open
sectasy0 opened this issue Jun 4, 2024 · 0 comments
Open

Array opperations #19

sectasy0 opened this issue Jun 4, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@sectasy0
Copy link
Owner

sectasy0 commented Jun 4, 2024

1. Insert

A.INSERT key index element
  • Description: Command allows to set a value at a specific index in an array.
  • Time Complexity: O(N) where N is the length of the array . Setting either the first or the last element of the array is O(1).

2. Push

A.PUSH key element [element ...]
  • Description: Insert all the specified values at the end of the array stored at key. If key doesn't exist an error is returned.
  • Time Complexity: O(1) for each element added, so O(N) to add N elements when the command is called with multiple arguments.

3. Get at

A.GET_AT key index
  • Description: Returns the element at index index in the array stored at key. The index is zero-based, so 0 means the first element, 1 the second element and so on. Negative indices can be used to designate elements starting at the tail of the list. Here, -1 means the last element, -2 means the penultimate and so forth. In case the value is not a array, an error is returned. When
  • Time Complexity: O(N) where N is the length of the array. Setting either the first or the last element of the array is O(1).

4. A.POP:

A.POP key
  • Description: Removes and returns the last elements of the array stored at key If key doesn't not exists an error is returned.
  • Time Complexity: O(1)

5. A.INDEX_OF:

A.INDEX_OF key value
  • Description: Returns the first index at which a given element can be found in the array, or -1 if it is not present. If key doesn't not exists an error is returned.
  • Time Complexity: O(N) where N is the number of elements.

6. A.DELETE:

A.DELETE key index
  • Description: Removes element at index from key if index < 0 then it should start from the end, for example -1 should delete the last one. If key doesn't not exists an error is returned
  • Time Complexity: O(N) where N is the number of elements.
@sectasy0 sectasy0 added the enhancement New feature or request label Jun 4, 2024
@sectasy0 sectasy0 added this to the 0.2.0 milestone Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant