[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/14: pmt: adding pmt::dict_update(dict1,
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/14: pmt: adding pmt::dict_update(dict1, dict2) function for merging dictionaries |
Date: |
Fri, 9 May 2014 22:28:42 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit fd6feaf2885a635a21b5955897b9d85e141e460c
Author: Tim O'Shea <address@hidden>
Date: Tue May 6 21:02:55 2014 -0400
pmt: adding pmt::dict_update(dict1, dict2) function for merging dictionaries
---
gnuradio-runtime/include/pmt/pmt.h | 3 +++
gnuradio-runtime/lib/pmt/pmt.cc | 13 +++++++++++++
gnuradio-runtime/swig/pmt_swig.i | 1 +
3 files changed, 17 insertions(+)
diff --git a/gnuradio-runtime/include/pmt/pmt.h
b/gnuradio-runtime/include/pmt/pmt.h
index 66cf1f7..3cae2f2 100644
--- a/gnuradio-runtime/include/pmt/pmt.h
+++ b/gnuradio-runtime/include/pmt/pmt.h
@@ -571,6 +571,9 @@ PMT_API pmt_t dict_items(pmt_t dict);
//! Return list of keys
PMT_API pmt_t dict_keys(pmt_t dict);
+//! Return a new dictionary \p dict1 with k=>v pairs from \p dict2 added.
+PMT_API pmt_t dict_update(const pmt_t &dict1, const pmt_t &dict2);
+
//! Return list of values
PMT_API pmt_t dict_values(pmt_t dict);
diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc
index a9907ca..7760c02 100644
--- a/gnuradio-runtime/lib/pmt/pmt.cc
+++ b/gnuradio-runtime/lib/pmt/pmt.cc
@@ -813,6 +813,19 @@ dict_add(const pmt_t &dict, const pmt_t &key, const pmt_t
&value)
}
pmt_t
+dict_update(const pmt_t &dict1, const pmt_t &dict2)
+{
+ pmt_t d(dict1);
+ pmt_t k(dict_keys(dict2));
+ while(is_pair(k)){
+ d = dict_add(d, car(k), dict_ref(dict2, car(k), PMT_NIL));
+ k = cdr(k);
+ }
+ return d;
+}
+
+
+pmt_t
dict_delete(const pmt_t &dict, const pmt_t &key)
{
if (is_null(dict))
diff --git a/gnuradio-runtime/swig/pmt_swig.i b/gnuradio-runtime/swig/pmt_swig.i
index d05a0b4..2c0444f 100644
--- a/gnuradio-runtime/swig/pmt_swig.i
+++ b/gnuradio-runtime/swig/pmt_swig.i
@@ -239,6 +239,7 @@ namespace pmt{
pmt_t dict_ref(const pmt_t &dict, const pmt_t &key, const pmt_t ¬_found);
pmt_t dict_items(pmt_t dict);
pmt_t dict_keys(pmt_t dict);
+ pmt_t dict_update(const pmt_t &dict1, const pmt_t &dict2);
pmt_t dict_values(pmt_t dict);
bool is_any(pmt_t obj);
- [Commit-gnuradio] [gnuradio] 11/14: Merge remote-tracking branch 'smunaut/fft-filter', (continued)
- [Commit-gnuradio] [gnuradio] 11/14: Merge remote-tracking branch 'smunaut/fft-filter', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 08/14: Merge remote-tracking branch 'osh/typo_fix', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 13/14: Merge branch 'maint', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 14/14: Merge remote-tracking branch 'tom/cmake_ice_libs', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 05/14: cmake: fixing up FindICE to handle more possible install cases., git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 01/14: cmake: better setup for finding QWT; otherwise, it can be forced to incorrectly "find" non-existent QWT libs., git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 09/14: gr-digital: update the HDLC blocks., git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 10/14: Merge branch 'hdlc_update', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 12/14: Merge remote-tracking branch 'osh/cpx_to_ishort_vector', git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 07/14: blocks: add vector output option param to complex_to_interleaved_short to match interleaved_short_to_complex, git, 2014/05/09
- [Commit-gnuradio] [gnuradio] 02/14: pmt: adding pmt::dict_update(dict1, dict2) function for merging dictionaries,
git <=
- [Commit-gnuradio] [gnuradio] 03/14: runtime: ieieieieieieieieieieieieieieieieieieieieieeieiieieieiieieieieieieieieieiieiieieiie, git, 2014/05/09