All Projects → garrison → UniqueVectors.jl

garrison / UniqueVectors.jl

Licence: other
Vectors of unique elements, with quick reverse lookups

Programming Languages

julia
2034 projects

Labels

Projects that are alternatives of or similar to UniqueVectors.jl

Miniboxing Plugin
Miniboxing is a program transformation that improves the performance of Scala generics when used with primitive types. It can speed up generic collections by factors between 1.5x and 22x, while maintaining bytecode duplication to a minimum. You can easily add miniboxing to your sbt project:
Stars: ✭ 106 (+430%)
Mutual labels:  arrays
algoexpert
AlgoExpert is an online platform that helps software engineers to prepare for coding and technical interviews.
Stars: ✭ 8 (-60%)
Mutual labels:  arrays
loops-e-arrays
Repositório do curso Estruturas de Repetição e Arrays com Java. Curso este oferecido pela Digital Innovation one e ministrado por mim.
Stars: ✭ 1,029 (+5045%)
Mutual labels:  arrays
Data Structures With Go
Data Structures with Go Language
Stars: ✭ 121 (+505%)
Mutual labels:  arrays
Postgresql For Doctrine
PostgreSQL enhancements for Doctrine. Provides support for advanced data types (json, jssnb, arrays), text search, array operators and jsonb specific functions.
Stars: ✭ 181 (+805%)
Mutual labels:  arrays
slice
A JavaScript implementation of Python's negative indexing and extended slice syntax.
Stars: ✭ 53 (+165%)
Mutual labels:  arrays
Typerep Map
⚡️Efficient implementation of Map with types as keys
Stars: ✭ 85 (+325%)
Mutual labels:  arrays
final-form-arrays
Array Mutators for 🏁 Final Form
Stars: ✭ 64 (+220%)
Mutual labels:  arrays
Array Explorer
⚡️ A resource to help figure out what JavaScript array method would be best to use at any given time
Stars: ✭ 2,512 (+12460%)
Mutual labels:  arrays
Ubigeo-Peru
Base de datos de departamentos, provincias y distritos del Perú (UBIGEO) actualizada al 2019 (El INEI ha actualizado hasta el 2016). SQL, JSON, XML, CSV, Arreglos PHP, YAML.
Stars: ✭ 113 (+465%)
Mutual labels:  arrays
Dsa Geeksclasses
DSA-Self Paced With Doubt Assistance Course Solutions in Python (Python 3)
Stars: ✭ 137 (+585%)
Mutual labels:  arrays
Interviewbit
Collection of Abhishek Agrawal's gists solutions for problems on https://www.interviewbit.com
Stars: ✭ 166 (+730%)
Mutual labels:  arrays
Algorithm-Implementation
This is our effort to collect the best implementations to tough algorithms. All codes are written in c++.
Stars: ✭ 16 (-20%)
Mutual labels:  arrays
React Collection Helpers
A suite of composable utility components to manipulate collections.
Stars: ✭ 109 (+445%)
Mutual labels:  arrays
arrays
Yii Array Helper
Stars: ✭ 41 (+105%)
Mutual labels:  arrays
Async Ray
Provide async/await callbacks for every, find, findIndex, filter, forEach, map, reduce, reduceRight and some methods in Array.
Stars: ✭ 102 (+410%)
Mutual labels:  arrays
interview-cookbook
A playground for learning DataStructures, Algorithms, and Object-Oriented Concepts.
Stars: ✭ 25 (+25%)
Mutual labels:  arrays
VBA-Better-Array
An array class for VBA providing features found in more modern languages
Stars: ✭ 77 (+285%)
Mutual labels:  arrays
SoftUni-Software-Engineering
SoftUni- Software Engineering
Stars: ✭ 47 (+135%)
Mutual labels:  arrays
DSA--GeeksForGeeks
DSA course solutions in C++ Jump to below directly for more problems
Stars: ✭ 47 (+135%)
Mutual labels:  arrays

UniqueVectors

version Build Status Coverage Status pkgeval

julia> import Pkg; Pkg.add("UniqueVectors")

UniqueVector is a data structure acts like a Vector of unique elements, but also maintains a dictionary that is updated in sync with the vector, which allows for quick O(1) lookup of the index of any element:

julia> using UniqueVectors

julia> uv = UniqueVector(["cat", "dog", "mouse"])
3-element UniqueVectors.UniqueVector{String}:
 "cat"
 "dog"
 "mouse"

julia> uv[1]
"cat"

julia> findfirst(isequal("dog"), uv)         # executes quickly via a dictionary lookup, not sequential search
2

As might be expected, UniqueVector supports many of the usual methods for Vector, but all operations enforce the condition that each element of the array must be unique (as defined by isequal). The mutating methods push!, pop!, and empty! are implemented as well, as these operations keep constant the indices of existing elements in the array, allowing the dictionary to be updated efficiently.

In addition, UniqueVector implements a mutating findfirst! method, which returns the index of an element if it exists in the array, or otherwise appends the element and returns its new index:

julia> findfirst!(isequal("cat"), uv)
1

julia> findfirst!(isequal("horse"), uv)
4

julia> uv
4-element UniqueVectors.UniqueVector{String}:
 "cat"
 "dog"
 "mouse"
 "horse"

UniqueVector is derived from an abstract type known as AbstractUniqueVector. This type is meant for anything that implements a fast bi-directional mapping between elements of a type T and integers from 1 to N. For some applications, it will be possible to have alternative implementations of this interface--ones that resemble an UniqueVector but can be calculated quickly on the fly (and may not need to be fully stored in memory). One notable example of this would be Lin Tables, which are often used in numerical exact diagonalization studies, and which are used to map each basis element of a quantum Hamiltonian to indices 1 through N.

(More generally, one might want an abstract type that represents any bidirectional mapping between two different sets (without one of them necessarily being contiguous integers from 1 to N). In this case, using findfirst may not be the appropriate interface, and I'd welcome any comments on this.)

Note: This package was formerly known as IndexedArrays (see issue #4).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].