Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

sparse-array

javascript sort sparse array keep indexes

December 7, 2023 by Tarik

Here’s one approach. It copies the defined array elements to a new array and saves their indexes. It sorts the new array and then puts the sorted results back into the indexes that were previously used. var a = []; a[0] = 3; a[1] = 2; a[2] = 6; a[7] = 4; a[8] = 5; … Read more

Categories javascript Tags javascript, sorting, sparse-array Leave a comment

SparseArray, check if key exists

July 30, 2023 by Tarik

You could use: Bitmap bitmap = cache.get(key, null); But understand that this is the same as get(key): Bitmap bitmap = cache.get(key); The best way to use get(key, default) is to provide a generic default case, something to is a valid substitute when the key is not found. But there is no good reason not to … Read more

Categories java Tags android, hashmap, java, sparse-array Leave a comment

Sparse matrices / arrays in Java

February 22, 2023 by Tarik

Sparsed arrays built with hashmaps are very inefficient for frequently read data. The most efficient implementations uses a Trie that allows access to a single vector where segments are distributed. A Trie can compute if an element is present in the table by performing only read-only TWO array indexing to get the effective position where … Read more

Categories java Tags algorithm, java, sparse-array, sparse-matrix Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa