Skip to content

Array opperations #19

@sectasy0

Description

@sectasy0

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions