Correct unordered_set/unordered_multiset template Key parameter name
This commit is contained in:
parent
404aa2c3db
commit
4a25ddbb97
7 changed files with 80 additions and 80 deletions
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
class unordered_set {
|
class unordered_set {
|
||||||
|
|
||||||
%typemap(javabase) std::unordered_set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
|
%typemap(javabase) std::unordered_set<Key> "java.util.AbstractSet<$typemap(jboxtype, Key)>"
|
||||||
%proxycode %{
|
%proxycode %{
|
||||||
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, Key)> collection) {
|
||||||
this();
|
this();
|
||||||
addAll(collection);
|
addAll(collection);
|
||||||
}
|
}
|
||||||
|
|
@ -57,34 +57,34 @@ class unordered_set {
|
||||||
return sizeImpl();
|
return sizeImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, Key)> collection) {
|
||||||
boolean didAddElement = false;
|
boolean didAddElement = false;
|
||||||
for (java.lang.Object object : collection) {
|
for (java.lang.Object object : collection) {
|
||||||
didAddElement |= add(($typemap(jboxtype, T))object);
|
didAddElement |= add(($typemap(jboxtype, Key))object);
|
||||||
}
|
}
|
||||||
|
|
||||||
return didAddElement;
|
return didAddElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
|
public java.util.Iterator<$typemap(jboxtype, Key)> iterator() {
|
||||||
return new java.util.Iterator<$typemap(jboxtype, T)>() {
|
return new java.util.Iterator<$typemap(jboxtype, Key)>() {
|
||||||
private Iterator curr;
|
private Iterator curr;
|
||||||
private Iterator end;
|
private Iterator end;
|
||||||
|
|
||||||
private java.util.Iterator<$typemap(jboxtype, T)> init() {
|
private java.util.Iterator<$typemap(jboxtype, Key)> init() {
|
||||||
curr = $javaclassname.this.begin();
|
curr = $javaclassname.this.begin();
|
||||||
end = $javaclassname.this.end();
|
end = $javaclassname.this.end();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public $typemap(jboxtype, T) next() {
|
public $typemap(jboxtype, Key) next() {
|
||||||
if (!hasNext()) {
|
if (!hasNext()) {
|
||||||
throw new java.util.NoSuchElementException();
|
throw new java.util.NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the current position, increment it,
|
// Save the current position, increment it,
|
||||||
// then return the value at the position before the increment.
|
// then return the value at the position before the increment.
|
||||||
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
|
final $typemap(jboxtype, Key) currValue = curr.derefUnchecked();
|
||||||
curr.incrementUnchecked();
|
curr.incrementUnchecked();
|
||||||
return currValue;
|
return currValue;
|
||||||
}
|
}
|
||||||
|
|
@ -106,11 +106,11 @@ class unordered_set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(java.lang.Object object) {
|
public boolean contains(java.lang.Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, T))) {
|
if (!(object instanceof $typemap(jboxtype, Key))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return containsImpl(($typemap(jboxtype, T))object);
|
return containsImpl(($typemap(jboxtype, Key))object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAll(java.util.Collection<?> collection) {
|
public boolean removeAll(java.util.Collection<?> collection) {
|
||||||
|
|
@ -123,11 +123,11 @@ class unordered_set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(java.lang.Object object) {
|
public boolean remove(java.lang.Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, T))) {
|
if (!(object instanceof $typemap(jboxtype, Key))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeImpl(($typemap(jboxtype, T))object);
|
return removeImpl(($typemap(jboxtype, Key))object);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ class unordered_set {
|
||||||
++(*$self);
|
++(*$self);
|
||||||
}
|
}
|
||||||
|
|
||||||
T derefUnchecked() const {
|
Key derefUnchecked() const {
|
||||||
return **$self;
|
return **$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,8 +152,8 @@ class unordered_set {
|
||||||
|
|
||||||
typedef size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
typedef T value_type;
|
typedef Key value_type;
|
||||||
typedef T key_type;
|
typedef Key key_type;
|
||||||
typedef value_type* pointer;
|
typedef value_type* pointer;
|
||||||
typedef const value_type* const_pointer;
|
typedef const value_type* const_pointer;
|
||||||
typedef value_type& reference;
|
typedef value_type& reference;
|
||||||
|
|
@ -172,17 +172,17 @@ class unordered_set {
|
||||||
%fragment("SWIG_UnorderedSetSize");
|
%fragment("SWIG_UnorderedSetSize");
|
||||||
|
|
||||||
// Returns whether item was inserted.
|
// Returns whether item was inserted.
|
||||||
bool add(const T& key) {
|
bool add(const Key& key) {
|
||||||
return self->insert(key).second;
|
return self->insert(key).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether set contains key.
|
// Returns whether set contains key.
|
||||||
bool containsImpl(const T& key) {
|
bool containsImpl(const Key& key) {
|
||||||
return (self->count(key) > 0);
|
return (self->count(key) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether the item was erased.
|
// Returns whether the item was erased.
|
||||||
bool removeImpl(const T& key) {
|
bool removeImpl(const Key& key) {
|
||||||
return (self->erase(key) > 0);
|
return (self->erase(key) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
%fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdUnorderedMultisetTraits","header",fragment="StdSequenceTraits")
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class T>
|
template <class SwigPySeq, class Key>
|
||||||
inline void
|
inline void
|
||||||
assign(const SwigPySeq& swigpyseq, std::unordered_multiset<T>* seq) {
|
assign(const SwigPySeq& swigpyseq, std::unordered_multiset<Key>* seq) {
|
||||||
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
|
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
|
||||||
typedef typename SwigPySeq::value_type value_type;
|
typedef typename SwigPySeq::value_type value_type;
|
||||||
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
||||||
|
|
@ -18,24 +18,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_reserve<std::unordered_multiset<T> > {
|
struct traits_reserve<std::unordered_multiset<Key> > {
|
||||||
static void reserve(std::unordered_multiset<T> &seq, typename std::unordered_multiset<T>::size_type n) {
|
static void reserve(std::unordered_multiset<Key> &seq, typename std::unordered_multiset<Key>::size_type n) {
|
||||||
seq.reserve(n);
|
seq.reserve(n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_asptr<std::unordered_multiset<T> > {
|
struct traits_asptr<std::unordered_multiset<Key> > {
|
||||||
static int asptr(PyObject *obj, std::unordered_multiset<T> **m) {
|
static int asptr(PyObject *obj, std::unordered_multiset<Key> **m) {
|
||||||
return traits_asptr_stdseq<std::unordered_multiset<T> >::asptr(obj, m);
|
return traits_asptr_stdseq<std::unordered_multiset<Key> >::asptr(obj, m);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_from<std::unordered_multiset<T> > {
|
struct traits_from<std::unordered_multiset<Key> > {
|
||||||
static PyObject *from(const std::unordered_multiset<T>& vec) {
|
static PyObject *from(const std::unordered_multiset<Key>& vec) {
|
||||||
return traits_from_stdseq<std::unordered_multiset<T> >::from(vec);
|
return traits_from_stdseq<std::unordered_multiset<Key> >::from(vec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
%fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdUnorderedSetTraits","header",fragment="StdSequenceTraits")
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class T>
|
template <class SwigPySeq, class Key>
|
||||||
inline void
|
inline void
|
||||||
assign(const SwigPySeq& swigpyseq, std::unordered_set<T>* seq) {
|
assign(const SwigPySeq& swigpyseq, std::unordered_set<Key>* seq) {
|
||||||
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
|
// seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
|
||||||
typedef typename SwigPySeq::value_type value_type;
|
typedef typename SwigPySeq::value_type value_type;
|
||||||
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
||||||
|
|
@ -16,24 +16,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_reserve<std::unordered_set<T> > {
|
struct traits_reserve<std::unordered_set<Key> > {
|
||||||
static void reserve(std::unordered_set<T> &seq, typename std::unordered_set<T>::size_type n) {
|
static void reserve(std::unordered_set<Key> &seq, typename std::unordered_set<Key>::size_type n) {
|
||||||
seq.reserve(n);
|
seq.reserve(n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_asptr<std::unordered_set<T> > {
|
struct traits_asptr<std::unordered_set<Key> > {
|
||||||
static int asptr(PyObject *obj, std::unordered_set<T> **s) {
|
static int asptr(PyObject *obj, std::unordered_set<Key> **s) {
|
||||||
return traits_asptr_stdseq<std::unordered_set<T> >::asptr(obj, s);
|
return traits_asptr_stdseq<std::unordered_set<Key> >::asptr(obj, s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_from<std::unordered_set<T> > {
|
struct traits_from<std::unordered_set<Key> > {
|
||||||
static PyObject *from(const std::unordered_set<T>& vec) {
|
static PyObject *from(const std::unordered_set<Key>& vec) {
|
||||||
return traits_from_stdseq<std::unordered_set<T> >::from(vec);
|
return traits_from_stdseq<std::unordered_set<Key> >::from(vec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
%fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits")
|
%fragment("StdUnorderedMultisetTraits","header",fragment="StdUnorderedSetTraits")
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class T>
|
template <class RubySeq, class Key>
|
||||||
inline void
|
inline void
|
||||||
assign(const RubySeq& rubyseq, std::unordered_multiset<T>* seq) {
|
assign(const RubySeq& rubyseq, std::unordered_multiset<Key>* seq) {
|
||||||
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
|
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
|
||||||
typedef typename RubySeq::value_type value_type;
|
typedef typename RubySeq::value_type value_type;
|
||||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||||
|
|
@ -18,17 +18,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_asptr<std::unordered_multiset<T> > {
|
struct traits_asptr<std::unordered_multiset<Key> > {
|
||||||
static int asptr(VALUE obj, std::unordered_multiset<T> **m) {
|
static int asptr(VALUE obj, std::unordered_multiset<Key> **m) {
|
||||||
return traits_asptr_stdseq<std::unordered_multiset<T> >::asptr(obj, m);
|
return traits_asptr_stdseq<std::unordered_multiset<Key> >::asptr(obj, m);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_from<std::unordered_multiset<T> > {
|
struct traits_from<std::unordered_multiset<Key> > {
|
||||||
static VALUE from(const std::unordered_multiset<T>& vec) {
|
static VALUE from(const std::unordered_multiset<Key>& vec) {
|
||||||
return traits_from_stdseq<std::unordered_multiset<T> >::from(vec);
|
return traits_from_stdseq<std::unordered_multiset<Key> >::from(vec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@
|
||||||
%fragment("StdUnorderedSetTraits","header",fragment="<stddef.h>",fragment="StdSetTraits")
|
%fragment("StdUnorderedSetTraits","header",fragment="<stddef.h>",fragment="StdSetTraits")
|
||||||
%{
|
%{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class T>
|
template <class RubySeq, class Key>
|
||||||
inline void
|
inline void
|
||||||
assign(const RubySeq& rubyseq, std::unordered_set<T>* seq) {
|
assign(const RubySeq& rubyseq, std::unordered_set<Key>* seq) {
|
||||||
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
|
// seq->insert(rubyseq.begin(), rubyseq.end()); // not used as not always implemented
|
||||||
typedef typename RubySeq::value_type value_type;
|
typedef typename RubySeq::value_type value_type;
|
||||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||||
|
|
@ -18,17 +18,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_asptr<std::unordered_set<T> > {
|
struct traits_asptr<std::unordered_set<Key> > {
|
||||||
static int asptr(VALUE obj, std::unordered_set<T> **s) {
|
static int asptr(VALUE obj, std::unordered_set<Key> **s) {
|
||||||
return traits_asptr_stdseq<std::unordered_set<T> >::asptr(obj, s);
|
return traits_asptr_stdseq<std::unordered_set<Key> >::asptr(obj, s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T>
|
template <class Key>
|
||||||
struct traits_from<std::unordered_set<T> > {
|
struct traits_from<std::unordered_set<Key> > {
|
||||||
static VALUE from(const std::unordered_set<T>& vec) {
|
static VALUE from(const std::unordered_set<Key>& vec) {
|
||||||
return traits_from_stdseq<std::unordered_set<T> >::from(vec);
|
return traits_from_stdseq<std::unordered_set<Key> >::from(vec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,19 @@
|
||||||
// const declarations are used to guess the intent of the function being
|
// const declarations are used to guess the intent of the function being
|
||||||
// exported; therefore, the following rationale is applied:
|
// exported; therefore, the following rationale is applied:
|
||||||
//
|
//
|
||||||
// -- f(std::unordered_multiset<T>), f(const std::unordered_multiset<T>&):
|
// -- f(std::unordered_multiset<Key>), f(const std::unordered_multiset<Key>&):
|
||||||
// the parameter being read-only, either a sequence or a
|
// the parameter being read-only, either a sequence or a
|
||||||
// previously wrapped std::unordered_multiset<T> can be passed.
|
// previously wrapped std::unordered_multiset<Key> can be passed.
|
||||||
// -- f(std::unordered_multiset<T>&), f(std::unordered_multiset<T>*):
|
// -- f(std::unordered_multiset<Key>&), f(std::unordered_multiset<Key>*):
|
||||||
// the parameter may be modified; therefore, only a wrapped std::unordered_multiset
|
// the parameter may be modified; therefore, only a wrapped std::unordered_multiset
|
||||||
// can be passed.
|
// can be passed.
|
||||||
// -- std::unordered_multiset<T> f(), const std::unordered_multiset<T>& f():
|
// -- std::unordered_multiset<Key> f(), const std::unordered_multiset<Key>& f():
|
||||||
// the set is returned by copy; therefore, a sequence of T:s
|
// the set is returned by copy; therefore, a sequence of Key:s
|
||||||
// is returned which is most easily used in other functions
|
// is returned which is most easily used in other functions
|
||||||
// -- std::unordered_multiset<T>& f(), std::unordered_multiset<T>* f():
|
// -- std::unordered_multiset<Key>& f(), std::unordered_multiset<Key>* f():
|
||||||
// the set is returned by reference; therefore, a wrapped std::unordered_multiset
|
// the set is returned by reference; therefore, a wrapped std::unordered_multiset
|
||||||
// is returned
|
// is returned
|
||||||
// -- const std::unordered_multiset<T>* f(), f(const std::unordered_multiset<T>*):
|
// -- const std::unordered_multiset<Key>* f(), f(const std::unordered_multiset<Key>*):
|
||||||
// for consistency, they expect and return a plain set pointer.
|
// for consistency, they expect and return a plain set pointer.
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,19 +50,19 @@
|
||||||
// const declarations are used to guess the intent of the function being
|
// const declarations are used to guess the intent of the function being
|
||||||
// exported; therefore, the following rationale is applied:
|
// exported; therefore, the following rationale is applied:
|
||||||
//
|
//
|
||||||
// -- f(std::unordered_set<T>), f(const std::unordered_set<T>&):
|
// -- f(std::unordered_set<Key>), f(const std::unordered_set<Key>&):
|
||||||
// the parameter being read-only, either a sequence or a
|
// the parameter being read-only, either a sequence or a
|
||||||
// previously wrapped std::unordered_set<T> can be passed.
|
// previously wrapped std::unordered_set<Key> can be passed.
|
||||||
// -- f(std::unordered_set<T>&), f(std::unordered_set<T>*):
|
// -- f(std::unordered_set<Key>&), f(std::unordered_set<Key>*):
|
||||||
// the parameter may be modified; therefore, only a wrapped std::unordered_set
|
// the parameter may be modified; therefore, only a wrapped std::unordered_set
|
||||||
// can be passed.
|
// can be passed.
|
||||||
// -- std::unordered_set<T> f(), const std::unordered_set<T>& f():
|
// -- std::unordered_set<Key> f(), const std::unordered_set<Key>& f():
|
||||||
// the unordered_set is returned by copy; therefore, a sequence of T:s
|
// the unordered_set is returned by copy; therefore, a sequence of Key:s
|
||||||
// is returned which is most easily used in other functions
|
// is returned which is most easily used in other functions
|
||||||
// -- std::unordered_set<T>& f(), std::unordered_set<T>* f():
|
// -- std::unordered_set<Key>& f(), std::unordered_set<Key>* f():
|
||||||
// the unordered_set is returned by reference; therefore, a wrapped std::unordered_set
|
// the unordered_set is returned by reference; therefore, a wrapped std::unordered_set
|
||||||
// is returned
|
// is returned
|
||||||
// -- const std::unordered_set<T>* f(), f(const std::unordered_set<T>*):
|
// -- const std::unordered_set<Key>* f(), f(const std::unordered_set<Key>*):
|
||||||
// for consistency, they expect and return a plain unordered_set pointer.
|
// for consistency, they expect and return a plain unordered_set pointer.
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue