Module util

Utility Functions.

Copyright © 2007-2015 Zuse Institute Berlin

Version: $Id$

Authors: Thorsten Schuett (schuett@zib.de).

Description

Utility Functions.

Data Types

accumulatorFun()

accumulatorFun(T, U) = fun((T, U) -> U)

args()

args() = [term()]

erlang_timestamp()

erlang_timestamp() = 
    {MegaSecs :: non_neg_integer(),
     Secs :: 0..999999,
     MicroSecs :: 0..999999}

repeat_params()

repeat_params() = 
    parallel | collect | {accumulate, accumulatorFun(any(), R), R}

{accumulate, fun, accumulator init value}

time_utc()

time_utc() = 
    {{1970..10000, 1..12, 1..31}, {0..23, 0..59, 0..59}}

us_timestamp()

us_timestamp() = non_neg_integer()

micro seconds since Epoch

Function Index

wait_for/1Executes wait_for/2 with a WaitTime of 10ms.
wait_for/2Waits for F/0 to become true and checks every WaitTime Milliseconds.
wait_for_process_to_die/1Waits for the given process (name or pid) to die.
wait_for_ets_table_to_disappear/2Waits for the given ets table to disappear.
ets_tables_of/1
escape_quotes/1Escapes quotes in the given string.
max/2Variant of erlang:max/2 also taking ?PLUS_INFINITY_TYPE and ?MINUS_INFINITY_TYPE into account, e.g.
min/2Variant of erlang:min/2 also taking ?PLUS_INFINITY_TYPE and ?MINUS_INFINITY_TYPE into account, e.g.
pow/2
log_feeder/2
log/2Logarithm of X to the base of Base.
log2_feeder/1
log2/1Logarithm of X to the base of 2.
log1p_feeder/1
log1p/1More precise version of ln(1+x) for small x.
pow1p_feeder/2
pow1p/2Calculates (1 - X^Y) more exactly, especially for X^Y near 1 (only really usefull for 0 < X < 1 - for the rest, use math:pow/2).
floor/1Returns the largest integer not larger than X.
ceil/1Returns the smallest integer not smaller than X.
logged_exec/1
get_stacktrace/0Gets the current stack trace.
get_linetrace/0
get_linetrace/1
do_throw/1
extract_from_list_may_not_exist/2Extracts a given ItemInfo from an ItemList or returns 'undefined' if there is no such item.
minus_all/2minus_all(M,N) : { x | x in M and x notin N}.
minus_first/2Deletes the first occurrence of each element in Excluded from List.
get_proc_in_vms/1
sleep_for_ever/0
randomelem/1Returns a random element from the given (non-empty!) list according to a uniform distribution.
randomelem_and_length/1Returns a random element from the given (non-empty!) list according to a uniform distribution (also returns the list's length).
pop_randomelem/1Removes a random element from the (non-empty!) list and returns the resulting list and the removed element.
pop_randomelem/2Removes a random element from the first Size elements of a (non-empty!) list and returns the resulting list and the removed element.
pop_randomsubset/2Removes a random subset of Size elements from the given list and returns the resulting list and the removed subset.
random_subset/2Returns a random subset of Size elements from the given list.
shuffle/1Fisher-Yates shuffling for lists.
gb_trees_largest_smaller_than/2Find the largest key in GBTree that is smaller than Key.
gb_trees_foldl/3Foldl over gb_trees.
tc/3Measures the execution time (in microseconds) for an MFA (does not catch exceptions as timer:tc/3 in older Erlang versions).
tc/2Measures the execution time (in microseconds) for Fun(Args) (does not catch exceptions as timer:tc/3 in older Erlang versions).
tc/1Measures the execution time (in microseconds) for Fun() (does not catch exceptions as timer:tc/3 in older Erlang versions).
zipfoldl/5
'=:<'/2Sorts like erlang:'=<'/2 but also defines the order of integers/floats representing the same value.
safe_split/2Splits off N elements from List.
split_unique/2Splits L1 into a list of elements that are not contained in L2, a list of elements that both lists share and a list of elements unique to L2.
split_unique/3Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2.
split_unique/4Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2.
ssplit_unique/2Splits L1 into a list of elements that are not contained in L2, a list of elements that both lists share and a list of elements unique to L2.
ssplit_unique/3Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2.
ssplit_unique/4Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2.
smerge2/2Merges two unique sorted lists into a single list.
smerge2/3Merges two unique Lte-sorted lists into a single list.
smerge2/4Merges two unique Lte-sorted lists into a single list.
smerge2/6Merges two unique Lte-sorted lists into a single list.
is_unittest/0Try to check whether common-test is running.
make_filename/1
app_get_env/2Get an application environment variable for the 'scalaris' application.
app_check_running/1check if App is allready running.
timestamp2us/1convert os:timestamp() to microsecs See http://erlang.org/pipermail/erlang-questions/2008-December/040368.html.
us2timestamp/1convert microsecs to os:timestamp().
time_plus_us/2
time_plus_ms/2
time_plus_s/2
readable_utc_time_feeder/1
readable_utc_time/1
for_to_fold/5
for_to/3for(i; i <= n; i++) { fun(i) }.
for_to_ex/4for(i; i <= n; i++) { Acc = [fun(i) | Acc] } (equal to lists:map(Fun, lists:seq(N,I,-1)) ++ Acc).
for_to_ex/3for(i; i <= n; i++) { Acc = [fun(i) | Acc] } (equal to lists:map(Fun, lists:seq(N,I,-1))).
map_with_nr_feeder/3
map_with_nr/3Similar to lists:map/2 but also passes the current number to the fun: [a, b, c,...] maps to [fun(a, StartNr), fun(b, StartNr+1), fun(c, StartNr+2),...]
par_map_feeder/2
par_map/2Parallel version of lists:map/2.
par_map_feeder/3
par_map/3Parallel version of lists:map/2 with the possibility to limit the maximum number of processes being spawned.
lists_take/2Delete an element from a list (once).
lists_takewith_feeder/2
lists_takewith/2Delete an element from a list (once) based on a predicate.
lists_split/2Splits the given list into several partitions, returning a list of parts of the original list.
lists_keystore2/5
lists_partition3_feeder/2
lists_partition3/2
lists_remove_at_indices/2
sublist/3A more flexible sublist function than lists:sublist/3.
lists_index_of/2If Element is in List, its index is returned (1..length(List) as in lists:nth/2), otherwise 'not_found'.
lists_check_min_length/2Checks whether the given list is at least the given length long without going through the whole list like erlang:length/1.
repeat/3Sequencial (default) or parallel run of function FUN with arguments ARGS TIMES-fold.
repeat/4
parallel_run/5
collect_while/1
list_set_nth/3
debug_info/0
debug_info/1
empty/1
print_bits/2
if_verbose/1
if_verbose/2
bin_xor/2Binary XOR for the two bitstrings, even for big bitstrings where the conversion to an integer fails.
bin_or/2Binary OR for the two bitstrings, even for big bitstrings where the conversion to an integer fails.
bin_and/2Binary AND for the two bitstrings, even for big bitstrings where the conversion to an integer fails.
extint2atom/1
sets_map/2
sets_equal/2Compare two sets for equality.
rrd_combine_timing_slots/3Combine the last N slots from a dump into one tuple.
rrd_combine_timing_slots/4
rrd_combine_gauge_slots/3This function does the same as rrd_combine_timing_slots, but for RRDs of type gauge.
rrd_combine_gauge_slots/4
rrd_combine_slots/6Accumulates data over RRD slots.
round/2Rounds a float according to some precision.

Function Details

wait_for/1

wait_for(F :: fun(() -> boolean())) -> ok

Executes wait_for/2 with a WaitTime of 10ms.

wait_for/2

wait_for(F :: fun(() -> boolean()), WaitTimeInMs :: pos_integer()) ->
            ok

Waits for F/0 to become true and checks every WaitTime Milliseconds. Uses (send_local_after/2 and receive) or timer:sleep/1 to wait to return control flow to e.g. proto_sched depending on whether the caller is a gen_component or not.

wait_for_process_to_die/1

wait_for_process_to_die(Name :: pid() | atom()) -> ok

Waits for the given process (name or pid) to die.

wait_for_ets_table_to_disappear/2

wait_for_ets_table_to_disappear(Pid :: pid(),
                                Table :: ets:tid() | atom()) ->
                                   ok

Waits for the given ets table to disappear.

ets_tables_of/1

ets_tables_of(Pid :: pid()) -> [ets:tid() | atom()]

escape_quotes/1

escape_quotes(String :: string()) -> string()

Escapes quotes in the given string.

max/2

max(X :: any(), B :: any()) -> any()

Variant of erlang:max/2 also taking ?PLUS_INFINITY_TYPE and ?MINUS_INFINITY_TYPE into account, e.g. for comparing keys.

min/2

min(X :: any(), B :: any()) -> any()

Variant of erlang:min/2 also taking ?PLUS_INFINITY_TYPE and ?MINUS_INFINITY_TYPE into account, e.g. for comparing keys.

pow/2

pow(X :: integer(), Y :: non_neg_integer()) -> integer()

log_feeder/2

log_feeder(X :: number(), Base :: number()) ->
              {number(), number()}

log/2

log(X :: number(), Base :: number()) -> float()

Logarithm of X to the base of Base.

log2_feeder/1

log2_feeder(X :: number()) -> {number()}

log2/1

log2(X :: number()) -> float()

Logarithm of X to the base of 2.

log1p_feeder/1

log1p_feeder(X :: number()) -> {number()}

log1p/1

log1p(X :: number()) -> float()

More precise version of ln(1+x) for small x.

from: David Goldberg. 1991. What every computer scientist should know about floating-point arithmetic. ACM Comput. Surv. 23, 1 (March 1991), 5-48. DOI=10.1145/103162.103163

pow1p_feeder/2

pow1p_feeder(X0 :: float(), Y0 :: float()) ->
                {X :: float(), Y :: float()}

pow1p/2

pow1p(X :: float(), Y :: float()) -> float()

Calculates (1 - X^Y) more exactly, especially for X^Y near 1 (only really usefull for 0 < X < 1 - for the rest, use math:pow/2). Uses the series representation of 1 - X^Y 1-X^Y = sum_(i=1)^infinity (- Y^i * log^i(X) / (i!)) from: Wolfram Alpha for x^y

floor/1

floor(X :: number()) -> integer()

Returns the largest integer not larger than X.

ceil/1

ceil(X :: number()) -> integer()

Returns the smallest integer not smaller than X.

logged_exec/1

logged_exec(Cmd :: string() | atom()) -> ok

get_stacktrace/0

get_stacktrace() ->
                  [{Module :: atom(),
                    Function :: atom(),
                    ArityOrArgs :: byte() | [term()]} |
                   {Module :: atom(),
                    Function :: atom(),
                    ArityOrArgs :: byte() | [term()],
                    Sources :: [term()]}]

Gets the current stack trace. Use this method in order to get a stack trace if no exception was thrown.

get_linetrace/0

get_linetrace() -> term() | undefined

get_linetrace/1

get_linetrace(Pid :: pid()) -> term() | undefined

do_throw/1

do_throw(Exception :: term()) -> no_return()

extract_from_list_may_not_exist/2

extract_from_list_may_not_exist(List ::
                                    [{Item :: term(),
                                      Info :: any()}],
                                ItemInfo :: term()) ->
                                   Info :: any() | undefined

Extracts a given ItemInfo from an ItemList or returns 'undefined' if there is no such item.

minus_all/2

minus_all(List :: [T], Excluded :: [T]) -> [T]

minus_all(M,N) : { x | x in M and x notin N}

minus_first/2

minus_first(List :: [T], Excluded :: [T]) -> [T]

Deletes the first occurrence of each element in Excluded from List. Similar to lists:foldl(fun lists:delete/2, NewValue1, ToDel) but more performant for out case.

get_proc_in_vms/1

get_proc_in_vms(Proc :: atom()) -> [comm:mypid()]

sleep_for_ever/0

sleep_for_ever() -> no_return()

randomelem/1

randomelem(List :: [X, ...]) -> X

Returns a random element from the given (non-empty!) list according to a uniform distribution.

randomelem_and_length/1

randomelem_and_length(List :: [X, ...]) ->
                         {X, Length :: pos_integer()}

Returns a random element from the given (non-empty!) list according to a uniform distribution (also returns the list's length).

pop_randomelem/1

pop_randomelem(List :: [X, ...]) ->
                  {NewList :: [X], PoppedElement :: X}

Removes a random element from the (non-empty!) list and returns the resulting list and the removed element.

pop_randomelem/2

pop_randomelem(List :: [X, ...], Size :: non_neg_integer()) ->
                  {NewList :: [X], PoppedElement :: X}

Removes a random element from the first Size elements of a (non-empty!) list and returns the resulting list and the removed element. If Size is 0, the first element will be popped. Size must not exceed the length of the list!

pop_randomsubset/2

pop_randomsubset(Size :: pos_integer(), List :: [X]) ->
                    {NewList :: [X], PoppedSet :: [X]}

Removes a random subset of Size elements from the given list and returns the resulting list and the removed subset. If Size is larger than the list length, all elements will be returned (in random order).

random_subset/2

random_subset(Size :: pos_integer(), List :: [T]) -> [T]

Returns a random subset of Size elements from the given list.

shuffle/1

shuffle(List :: [T]) -> [T]

Fisher-Yates shuffling for lists.

gb_trees_largest_smaller_than/2

gb_trees_largest_smaller_than(Key,
                              X2 :: gb_trees:tree(Key, Value)) ->
                                 {value, Key, Value} | nil

Find the largest key in GBTree that is smaller than Key. Note: gb_trees offers only linear traversal or lookup of exact keys - we implement a more flexible binary search here despite gb_tree being defined as opaque.

gb_trees_foldl/3

gb_trees_foldl(F :: fun((Key, Value, Acc) -> Acc),
               Acc,
               GBTree :: gb_trees:tree(Key, Value)) ->
                  Acc

Foldl over gb_trees.

tc/3

tc(M :: module(), F :: atom(), A :: list()) -> {integer(), term()}

Measures the execution time (in microseconds) for an MFA (does not catch exceptions as timer:tc/3 in older Erlang versions).

tc/2

tc(Fun :: function(), Args :: list()) -> {integer(), term()}

Measures the execution time (in microseconds) for Fun(Args) (does not catch exceptions as timer:tc/3 in older Erlang versions).

tc/1

tc(Fun :: function()) -> {integer(), term()}

Measures the execution time (in microseconds) for Fun() (does not catch exceptions as timer:tc/3 in older Erlang versions).

zipfoldl/5

zipfoldl(ZipFun :: fun((X, Y) -> Z),
         FoldFun :: fun((Z, Acc) -> Acc),
         L1 :: [X],
         L2 :: [Y],
         Acc) ->
            Acc

'=:<'/2

'=:<'(T, T) -> boolean()

Sorts like erlang:'=<'/2 but also defines the order of integers/floats representing the same value.

safe_split/2

safe_split(N :: non_neg_integer(), List :: [T]) ->
              {FirstN :: [T], Rest :: [T]}

Splits off N elements from List. If List is not large enough, the whole list is returned.

split_unique/2

split_unique(L1 :: [X], L2 :: [X]) ->
                {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that both lists share and a list of elements unique to L2. Returned lists are sorted and contain no duplicates.

split_unique/3

split_unique(L1 :: [X],
             L2 :: [X],
             Lte :: fun((X, X) -> boolean())) ->
                {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2. When two elements compare equal, the element from List1 is picked. Lte(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise. Returned lists are sorted according to Lte and contain no duplicates.

split_unique/4

split_unique(L1 :: [X],
             L2 :: [X],
             Lte :: fun((X, X) -> boolean()),
             EqSelect :: fun((X, X) -> X)) ->
                {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2. When two elements compare equal, EqSelect(element(L1), element(L2)) chooses which of them to take. Lte(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise. Returned lists are sorted according to Lte and contain no duplicates.

ssplit_unique/2

ssplit_unique(L1 :: [X], L2 :: [X]) ->
                 {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that both lists share and a list of elements unique to L2. Both lists must be sorted. Returned lists are sorted as well.

ssplit_unique/3

ssplit_unique(L1 :: [X],
              L2 :: [X],
              Lte :: fun((X, X) -> boolean())) ->
                 {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2. When two elements compare equal, the element from List1 is picked. Both lists must be sorted according to Lte. Lte(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise. Returned lists are sorted according to Lte.

ssplit_unique/4

ssplit_unique(L1 :: [X],
              L2 :: [X],
              Lte :: fun((X, X) -> boolean()),
              EqSelect :: fun((X, X) -> X)) ->
                 {UniqueL1 :: [X], Shared :: [X], UniqueL2 :: [X]}

Splits L1 into a list of elements that are not contained in L2, a list of elements that are equal in both lists (according to the ordering function Lte) and a list of elements unique to L2. When two elements compare equal, EqSelect(element(L1), element(L2)) chooses which of them to take. Both lists must be sorted according to Lte. Lte(A, B) should return true if A compares less than or equal to B in the ordering, false otherwise. Returned lists are sorted according to Lte.

smerge2/2

smerge2(L1 :: [X], L2 :: [X]) -> MergedList :: [X]

Merges two unique sorted lists into a single list.

smerge2/3

smerge2(L1 :: [X], L2 :: [X], Lte :: fun((X, X) -> boolean())) ->
           MergedList :: [X]

Merges two unique Lte-sorted lists into a single list.

smerge2/4

smerge2(L1 :: [X],
        L2 :: [X],
        Lte :: fun((X, X) -> boolean()),
        EqSelect :: fun((X, X) -> [X])) ->
           MergedList :: [X]

Merges two unique Lte-sorted lists into a single list.

smerge2/6

smerge2(L1 :: [X],
        L2 :: [X],
        Lte :: fun((X, X) -> boolean()),
        EqSelect :: fun((X, X) -> [X]),
        FirstExist :: fun((X) -> [X]),
        SecondExist :: fun((X) -> [X])) ->
           MergedList :: [X]

Merges two unique Lte-sorted lists into a single list.

is_unittest/0

is_unittest() -> boolean()

Try to check whether common-test is running.

make_filename/1

make_filename(Name :: [byte()]) -> string()

app_get_env/2

app_get_env(Var :: atom(), Default :: T) -> T

Get an application environment variable for the 'scalaris' application. If the variable is undefined, Default is returned.

app_check_running/1

app_check_running(App :: atom()) -> boolean()

check if App is allready running.

timestamp2us/1

timestamp2us(X1 :: erlang_timestamp()) -> us_timestamp()

convert os:timestamp() to microsecs See http://erlang.org/pipermail/erlang-questions/2008-December/040368.html

us2timestamp/1

us2timestamp(Time :: us_timestamp()) -> erlang_timestamp()

convert microsecs to os:timestamp()

time_plus_us/2

time_plus_us(Time :: erlang_timestamp(),
             Delta_MicroSeconds :: non_neg_integer()) ->
                erlang_timestamp()

time_plus_ms/2

time_plus_ms(Time :: erlang_timestamp(),
             Delta_MilliSeconds :: non_neg_integer()) ->
                erlang_timestamp()

time_plus_s/2

time_plus_s(Time :: erlang_timestamp(),
            Delta_Seconds :: non_neg_integer()) ->
               erlang_timestamp()

readable_utc_time_feeder/1

readable_utc_time_feeder(X1 :: {0..1000, 0..1000, 0..1000}) ->
                            {erlang_timestamp()}

readable_utc_time/1

readable_utc_time(TimeTriple :: erlang_timestamp()) -> tuple()

for_to_fold/5

for_to_fold(I :: integer(),
            N :: integer(),
            Fun :: fun((integer()) -> X),
            AccFun :: fun((X, Acc) -> Acc),
            AccIn :: Acc) ->
               Acc

for_to/3

for_to(I :: integer(),
       N :: integer(),
       Fun :: fun((integer()) -> any())) ->
          ok

for(i; i <= n; i++) { fun(i) }

for_to_ex/4

for_to_ex(I :: integer(),
          N :: integer(),
          Fun :: fun((integer()) -> T),
          Acc :: [T]) ->
             [T]

for(i; i <= n; i++) { Acc = [fun(i) | Acc] } (equal to lists:map(Fun, lists:seq(N,I,-1)) ++ Acc).

for_to_ex/3

for_to_ex(I :: integer(),
          N :: integer(),
          Fun :: fun((integer()) -> T)) ->
             [T]

for(i; i <= n; i++) { Acc = [fun(i) | Acc] } (equal to lists:map(Fun, lists:seq(N,I,-1))).

map_with_nr_feeder/3

map_with_nr_feeder(X1 :: 1..2,
                   List :: [number()],
                   StartNr :: integer()) ->
                      {Fun ::
                           fun((number(), integer()) -> number()),
                       List :: [number()],
                       integer()}

map_with_nr/3

map_with_nr(F :: fun((A, integer()) -> B),
            List :: [A],
            StartNr :: integer()) ->
               [B]

Similar to lists:map/2 but also passes the current number to the fun: [a, b, c,...] maps to [fun(a, StartNr), fun(b, StartNr+1), fun(c, StartNr+2),...]

par_map_feeder/2

par_map_feeder(X1 :: 1..2, List :: [number()]) ->
                  {Fun :: fun((number()) -> number()),
                   List :: [number()]}

par_map/2

par_map(Fun :: fun((A) -> B), List :: [A]) -> [B]

Parallel version of lists:map/2. Spawns a new process for each element in the list!

par_map_feeder/3

par_map_feeder(FunNr :: 1..2,
               List :: [number()],
               MaxThreads :: 1..50) ->
                  {Fun :: fun((number()) -> number()),
                   List :: [number()],
                   1..50}

par_map/3

par_map(Fun :: fun((A) -> B),
        List :: [A],
        MaxThreads :: pos_integer()) ->
           [B]

Parallel version of lists:map/2 with the possibility to limit the maximum number of processes being spawned.

lists_take/2

lists_take(T, L :: [T]) -> [T] | false

Delete an element from a list (once). When not found, return false.

lists_takewith_feeder/2

lists_takewith_feeder(Elem :: T, L :: [T]) ->
                         {fun((T) -> boolean()), [T]}

lists_takewith/2

lists_takewith(Pred :: fun((T) -> boolean()), L :: [T]) ->
                  {T, [T]} | false

Delete an element from a list (once) based on a predicate. When not found, return false.

lists_split/2

lists_split(List :: [A], Partitions :: pos_integer()) -> [[A]]

Splits the given list into several partitions, returning a list of parts of the original list. Both the parts and their contents are reversed compared to the original list!

lists_keystore2/5

lists_keystore2(Key :: term(),
                NC :: pos_integer(),
                List :: [tuple()],
                NS :: pos_integer(),
                NewValue :: term()) ->
                   [tuple()]

lists_partition3_feeder/2

lists_partition3_feeder(X1 :: will_fill_pred, List :: [integer()]) ->
                           {fun((integer()) -> 1..3), [integer()]}

lists_partition3/2

lists_partition3(Pred :: fun((Elem :: T) -> 1..3), List :: [T]) ->
                    {Pred1 :: [T], Pred2 :: [T], Pred3 :: [T]}

lists_remove_at_indices/2

lists_remove_at_indices(List :: [any(), ...],
                        Indices :: [non_neg_integer(), ...]) ->
                           [any()]

sublist/3

sublist(List :: [X, ...],
        Start :: pos_integer() | neg_integer(),
        Length :: integer()) ->
           {[X], Length :: non_neg_integer()}

A more flexible sublist function than lists:sublist/3. Extracts a sublist of length Length starting at Start. If Start is negative, we count from the end, e.g. -1 is the last element, -2 the second last. If Length is negative, the sublist is created in reversed direction, e.g. sublist([a,b,c], -1, -2) gets [c, b]. If Start is less than -ListLength and Length is non-negative, it will be set to 1. If Length is negative in this case, an empty sublist will be returned. If Start is greater than ListLength and Length is non-negative, an empty sublist will be returned. If Length is negative in this case, it will be set to ListLength. Note: sublists never wrap between start and end, i.e. sublist([a,b,c], 1, -2) gets []! Examples: * first 10: sublist(L, 1, 10) | sublist(L, 10, -10) (reverse order) * last 10 : sublist(L, -10, 10) | sublist(L, -1, -10) (reverse order)

lists_index_of/2

lists_index_of(Element :: T, List :: [T]) ->
                  pos_integer() | not_found

If Element is in List, its index is returned (1..length(List) as in lists:nth/2), otherwise 'not_found'.

lists_check_min_length/2

lists_check_min_length(List :: [any()], I :: non_neg_integer()) ->
                          boolean()

Checks whether the given list is at least the given length long without going through the whole list like erlang:length/1.

repeat/3

repeat(Fun :: function(), Args :: args(), Times :: pos_integer()) ->
          ok

Sequencial (default) or parallel run of function FUN with arguments ARGS TIMES-fold. Options as list/propertylist: collect, parallel, accumulate * collect (atom): all results of FUN will returned as a list * accumulate (tuple): {accumulate, accFun, accInit} all results will be accumulated with accFun * parallel (atom): FUN will be called TIMES-fold in parallel. Combination with collect and accumulate is supported.

repeat/4

repeat(Fun :: function(),
       Args :: args(),
       Times :: pos_integer(),
       Params :: [repeat_params()]) ->
          ok | any()

parallel_run/5

parallel_run(SrcPid :: pid(),
             Fun :: function(),
             Args :: args(),
             DoAnswer :: boolean(),
             Id :: any()) ->
                ok

collect_while/1

collect_while(GatherFun ::
                  fun((non_neg_integer()) ->
                          {boolean(), T} | boolean())) ->
                 [T]

list_set_nth/3

list_set_nth(L :: [A], Pos :: pos_integer(), B) -> [A | B]

debug_info/0

debug_info() -> [[{string(), string() | number()}]]

debug_info/1

debug_info(PidName :: pid()) -> [{string(), term()}]

empty/1

empty(X1 :: any()) -> []

print_bits/2

print_bits(FormatFun :: fun((string(), [term()]) -> Result),
           Binary :: binary()) ->
              Result

if_verbose/1

if_verbose(String :: string()) -> ok

if_verbose/2

if_verbose(String :: string(), Fmt :: list()) -> ok

bin_xor/2

bin_xor(Binary1 :: bitstring(), Binary2 :: bitstring()) ->
           bitstring()

Binary XOR for the two bitstrings, even for big bitstrings where the conversion to an integer fails. Note: 0's are appended if the sizes do not match.

bin_or/2

bin_or(Binary1 :: bitstring(), Binary2 :: bitstring()) ->
          bitstring()

Binary OR for the two bitstrings, even for big bitstrings where the conversion to an integer fails. Note: 0's are appended if the sizes do not match.

bin_and/2

bin_and(Binary1 :: bitstring(), Binary2 :: bitstring()) ->
           bitstring()

Binary AND for the two bitstrings, even for big bitstrings where the conversion to an integer fails. Note: 0's are appended if the sizes do not match.

extint2atom/1

extint2atom(X :: atom() | integer()) -> atom()

sets_map/2

sets_map(Fun :: fun((V) -> X), Set :: sets:set(V)) -> [X]

sets_equal/2

sets_equal(Set1 :: sets:set(V), Set2 :: sets:set(V)) -> boolean()

Compare two sets for equality.

rrd_combine_timing_slots/3

rrd_combine_timing_slots(DB :: rrd:rrd(),
                         CurrentTS :: erlang_timestamp(),
                         Interval :: non_neg_integer()) ->
                            {Sum :: number(),
                             SquaresSum :: number(),
                             Count :: non_neg_integer(),
                             Min :: number(),
                             Max :: number()} |
                            undefined

Combine the last N slots from a dump into one tuple. The number of slots to combine is determined by Interval (in us): Take as many slots as needed to look Interval-Epsilon microseconds back into the past.

rrd_combine_timing_slots/4

rrd_combine_timing_slots(DB :: rrd:rrd(),
                         CurrentTS :: erlang_timestamp(),
                         Interval :: non_neg_integer(),
                         Epsilon :: non_neg_integer()) ->
                            {Sum :: number(),
                             SquaresSum :: number(),
                             Count :: non_neg_integer(),
                             Min :: number(),
                             Max :: number()} |
                            undefined

rrd_combine_gauge_slots/3

rrd_combine_gauge_slots(DB :: rrd:rrd(),
                        CurrentTS :: erlang_timestamp(),
                        Interval :: non_neg_integer()) ->
                           Value :: number() | undefined

This function does the same as rrd_combine_timing_slots, but for RRDs of type gauge. It sums up slots until enough slots have been read.

rrd_combine_gauge_slots/4

rrd_combine_gauge_slots(DB :: rrd:rrd(),
                        CurrentTS :: erlang_timestamp(),
                        Interval :: non_neg_integer(),
                        Epsilon :: non_neg_integer()) ->
                           Value :: number() | undefined

rrd_combine_slots/6

rrd_combine_slots(DB :: rrd:rrd(),
                  CurrentTS :: erlang_timestamp(),
                  Interval :: non_neg_integer(),
                  Epsilon :: non_neg_integer(),
                  InitialValue :: fun((rrd:data_type()) -> Acc),
                  UpdateValue ::
                      fun((Acc, rrd:data_type()) -> Acc)) ->
                     term() | undefined

Accumulates data over RRD slots. This function allows to reduce a number of slots into a single accumulator value. The amount of slots is determined by Interval and Epsilon: it reads as many slots as needed to cover the last Interval - Epsilon us.

round/2

round(Number :: float(), Precision :: pos_integer()) -> float()

Rounds a float according to some precision


Generated by EDoc, Aug 2 2016, 13:43:27.