Created
December 3, 2013 03:28
-
-
Save milktrader/7763432 to your computer and use it in GitHub Desktop.
sort SerialArray
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract AbstractSeries | |
immutable SerialPair{T, V} <: AbstractSeries | |
index::T | |
value::V | |
end | |
type SerialArray{T,V} <: AbstractSeries | |
collection::Array{SerialPair{T,V},1} # this prevents arrays of mixed types | |
idxname::String | |
valname::String | |
end | |
# construct a SerialArray | |
foo = SerialPair(1, 10); bar = SerialPair(12, 15); baz = SerialPair(4, 459) | |
sa = SerialArray([foo, bar, baz]) | |
# show code not provided, but this is what it looks like: | |
index values | |
1 10 | |
12 15 | |
4 459 | |
# and we need an inner constructor that enforces the array is sorted by the index field of the SerialPair | |
Author
milktrader
commented
Dec 3, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment