GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - selfsame/soa: clojure Structure of Arrays data type

BranchesTags
Open more actions menu

Latest commit

 

History

8 Commits
8 Commits

Folders and files

NameName
Last commit message
Last commit date
src/soa
src/soa
 
 
tests/soa
tests/soa
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
project.clj
project.clj
 
 
soa.sublime-project
soa.sublime-project
 
 

Repository files navigation

soa

clojure structure of arrays data type

clojars

[selfsame/soa "0.6-SNAPSHOT"]

Soa graphs provide lower memory usage for collections of homogeneous data.

Briefly, instead of a vector of maps

[{:a 1, :b 2} 
 {:a 3, :b 4}]

they're a map of vectors.

{:a [1 3]
 :b [2 4]}

usage

soa.core/Graph behaves like a vector, and maintains the internal SoA map.

(require 'soa.core)

(graph [{:a 1}{:b 2}])
;#soa/graph [{:a 1, :b nil}{:a nil, :b 2}]

(.-rec g)
;{:a [1 nil], :b [nil 2]}

(into g g)
;#soa/graph [{:a 1, :b nil}{:a nil, :b 2}{:a 1, :b nil}{:a nil, :b 2}]

The introduction of novel keys affects all items.

(conj g {:c 3})
;#soa/graph [{:a 1, :b nil, :c nil}{:a nil, :b 2, :c nil}{:a nil, :b nil, :c 3}]

iterating graphs returns instances of soa.core/Node, a wrapper for the graph and index. Nodes behave like maps.

(first g)
;#soa/node {:a 1, :b nil}

(.-index (first g))
;0

(map :a g)
;(1 nil)

(soa.core/gget g 0)
;{:a 1, :b nil}

Use gupdate and gassoc to alter a graph.

(gupdate g 0 :b dec)
;#soa/graph [{:a 1, :b -1}{:a nil, :b 2}]

(gassoc g 1 :z 3)
;#soa/graph [{:a 1, :b nil, :z nil}{:a nil, :b 2, :z 3}]

About

clojure Structure of Arrays data type

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.