Replicate some cosmetic changes from std_map.i
into std_set.i, std_unordered_map.i, std_unordered_set.i.
This commit is contained in:
parent
d06ffe1087
commit
437037a3e6
4 changed files with 49 additions and 49 deletions
|
|
@ -112,7 +112,7 @@ template<class KeyType, class MappedType, class Comparator = std::less<KeyType>
|
||||||
|
|
||||||
Iterator itr = begin();
|
Iterator itr = begin();
|
||||||
final Iterator end = end();
|
final Iterator end = end();
|
||||||
while(itr.isNot(end)) {
|
while (itr.isNot(end)) {
|
||||||
setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() {
|
setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() {
|
||||||
private Iterator iterator;
|
private Iterator iterator;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template <class KeyType>
|
template <class T>
|
||||||
class set {
|
class set {
|
||||||
|
|
||||||
%typemap(javabase) std::set<KeyType> "java.util.AbstractSet<$typemap(jboxtype, KeyType)>"
|
%typemap(javabase) std::set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
|
||||||
%proxycode %{
|
%proxycode %{
|
||||||
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, KeyType)> collection) {
|
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
||||||
this();
|
this();
|
||||||
addAll(collection);
|
addAll(collection);
|
||||||
}
|
}
|
||||||
|
|
@ -57,34 +57,34 @@ class set {
|
||||||
return sizeImpl();
|
return sizeImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, KeyType)> collection) {
|
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
||||||
boolean didAddElement = false;
|
boolean didAddElement = false;
|
||||||
for (Object object : collection) {
|
for (Object object : collection) {
|
||||||
didAddElement |= add(($typemap(jboxtype, KeyType))object);
|
didAddElement |= add(($typemap(jboxtype, T))object);
|
||||||
}
|
}
|
||||||
|
|
||||||
return didAddElement;
|
return didAddElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() {
|
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
|
||||||
return new java.util.Iterator<$typemap(jboxtype, KeyType)>() {
|
return new java.util.Iterator<$typemap(jboxtype, T)>() {
|
||||||
private Iterator curr;
|
private Iterator curr;
|
||||||
private Iterator end;
|
private Iterator end;
|
||||||
|
|
||||||
private java.util.Iterator<$typemap(jboxtype, KeyType)> init() {
|
private java.util.Iterator<$typemap(jboxtype, T)> init() {
|
||||||
curr = $javaclassname.this.begin();
|
curr = $javaclassname.this.begin();
|
||||||
end = $javaclassname.this.end();
|
end = $javaclassname.this.end();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public $typemap(jboxtype, KeyType) next() {
|
public $typemap(jboxtype, T) 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, KeyType) currValue = curr.derefUnchecked();
|
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
|
||||||
curr.incrementUnchecked();
|
curr.incrementUnchecked();
|
||||||
return currValue;
|
return currValue;
|
||||||
}
|
}
|
||||||
|
|
@ -106,11 +106,11 @@ class set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object object) {
|
public boolean contains(Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, KeyType))) {
|
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return containsImpl(($typemap(jboxtype, KeyType))object);
|
return containsImpl(($typemap(jboxtype, T))object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAll(java.util.Collection<?> collection) {
|
public boolean removeAll(java.util.Collection<?> collection) {
|
||||||
|
|
@ -123,11 +123,11 @@ class set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean remove(Object object) {
|
public boolean remove(Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, KeyType))) {
|
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeImpl(($typemap(jboxtype, KeyType))object);
|
return removeImpl(($typemap(jboxtype, T))object);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -140,23 +140,23 @@ class set {
|
||||||
++(*$self);
|
++(*$self);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyType derefUnchecked() const {
|
T derefUnchecked() const {
|
||||||
return **$self;
|
return **$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNot(const iterator other) const {
|
bool isNot(iterator other) const {
|
||||||
return (*$self != other);
|
return (*$self != other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef KeyType key_type;
|
typedef T key_type;
|
||||||
typedef KeyType value_type;
|
typedef T value_type;
|
||||||
typedef size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
|
|
||||||
set();
|
set();
|
||||||
set(const set<KeyType>&);
|
set(const set<T>&);
|
||||||
|
|
||||||
%rename(isEmpty) empty;
|
%rename(isEmpty) empty;
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
@ -168,17 +168,17 @@ class set {
|
||||||
%fragment("SWIG_SetSize");
|
%fragment("SWIG_SetSize");
|
||||||
|
|
||||||
// Returns whether item was inserted.
|
// Returns whether item was inserted.
|
||||||
bool add(const KeyType& key) {
|
bool add(const T& key) {
|
||||||
return self->insert(key).second;
|
return self->insert(key).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether set contains key.
|
// Returns whether set contains key.
|
||||||
bool containsImpl(const KeyType& key) {
|
bool containsImpl(const T& 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 KeyType& key) {
|
bool removeImpl(const T& key) {
|
||||||
return (self->erase(key) > 0);
|
return (self->erase(key) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,4 +192,4 @@ class set {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace std
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ template<class KeyType, class MappedType > class unordered_map {
|
||||||
|
|
||||||
Iterator itr = begin();
|
Iterator itr = begin();
|
||||||
final Iterator end = end();
|
final Iterator end = end();
|
||||||
while(itr.isNot(end)) {
|
while (itr.isNot(end)) {
|
||||||
setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() {
|
setToReturn.add(new Entry<$typemap(jboxtype, KeyType), $typemap(jboxtype, MappedType)>() {
|
||||||
private Iterator iterator;
|
private Iterator iterator;
|
||||||
|
|
||||||
|
|
@ -159,7 +159,7 @@ template<class KeyType, class MappedType > class unordered_map {
|
||||||
return ++copy;
|
return ++copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNot(const iterator other) const {
|
bool isNot(iterator other) const {
|
||||||
return (*$self != other);
|
return (*$self != other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
||||||
template <class KeyType>
|
template <class T>
|
||||||
class unordered_set {
|
class unordered_set {
|
||||||
|
|
||||||
%typemap(javabase) std::unordered_set<KeyType> "java.util.AbstractSet<$typemap(jboxtype, KeyType)>"
|
%typemap(javabase) std::unordered_set<T> "java.util.AbstractSet<$typemap(jboxtype, T)>"
|
||||||
%proxycode %{
|
%proxycode %{
|
||||||
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, KeyType)> collection) {
|
public $javaclassname(java.util.Collection<? extends $typemap(jboxtype, T)> 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, KeyType)> collection) {
|
public boolean addAll(java.util.Collection<? extends $typemap(jboxtype, T)> collection) {
|
||||||
boolean didAddElement = false;
|
boolean didAddElement = false;
|
||||||
for (Object object : collection) {
|
for (Object object : collection) {
|
||||||
didAddElement |= add(($typemap(jboxtype, KeyType))object);
|
didAddElement |= add(($typemap(jboxtype, T))object);
|
||||||
}
|
}
|
||||||
|
|
||||||
return didAddElement;
|
return didAddElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public java.util.Iterator<$typemap(jboxtype, KeyType)> iterator() {
|
public java.util.Iterator<$typemap(jboxtype, T)> iterator() {
|
||||||
return new java.util.Iterator<$typemap(jboxtype, KeyType)>() {
|
return new java.util.Iterator<$typemap(jboxtype, T)>() {
|
||||||
private Iterator curr;
|
private Iterator curr;
|
||||||
private Iterator end;
|
private Iterator end;
|
||||||
|
|
||||||
private java.util.Iterator<$typemap(jboxtype, KeyType)> init() {
|
private java.util.Iterator<$typemap(jboxtype, T)> init() {
|
||||||
curr = $javaclassname.this.begin();
|
curr = $javaclassname.this.begin();
|
||||||
end = $javaclassname.this.end();
|
end = $javaclassname.this.end();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public $typemap(jboxtype, KeyType) next() {
|
public $typemap(jboxtype, T) 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, KeyType) currValue = curr.derefUnchecked();
|
final $typemap(jboxtype, T) currValue = curr.derefUnchecked();
|
||||||
curr.incrementUnchecked();
|
curr.incrementUnchecked();
|
||||||
return currValue;
|
return currValue;
|
||||||
}
|
}
|
||||||
|
|
@ -106,11 +106,11 @@ class unordered_set {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(Object object) {
|
public boolean contains(Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, KeyType))) {
|
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return containsImpl(($typemap(jboxtype, KeyType))object);
|
return containsImpl(($typemap(jboxtype, T))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(Object object) {
|
public boolean remove(Object object) {
|
||||||
if (!(object instanceof $typemap(jboxtype, KeyType))) {
|
if (!(object instanceof $typemap(jboxtype, T))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return removeImpl(($typemap(jboxtype, KeyType))object);
|
return removeImpl(($typemap(jboxtype, T))object);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -140,23 +140,23 @@ class unordered_set {
|
||||||
++(*$self);
|
++(*$self);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyType derefUnchecked() const {
|
T derefUnchecked() const {
|
||||||
return **$self;
|
return **$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNot(const iterator other) const {
|
bool isNot(iterator other) const {
|
||||||
return (*$self != other);
|
return (*$self != other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef KeyType key_type;
|
typedef T key_type;
|
||||||
typedef KeyType value_type;
|
typedef T value_type;
|
||||||
typedef size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
|
|
||||||
unordered_set();
|
unordered_set();
|
||||||
unordered_set(const unordered_set<KeyType>&);
|
unordered_set(const unordered_set<T>&);
|
||||||
|
|
||||||
%rename(isEmpty) empty;
|
%rename(isEmpty) empty;
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
@ -168,17 +168,17 @@ class unordered_set {
|
||||||
%fragment("SWIG_UnorderedSetSize");
|
%fragment("SWIG_UnorderedSetSize");
|
||||||
|
|
||||||
// Returns whether item was inserted.
|
// Returns whether item was inserted.
|
||||||
bool add(const KeyType& key) {
|
bool add(const T& key) {
|
||||||
return self->insert(key).second;
|
return self->insert(key).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether set contains key.
|
// Returns whether set contains key.
|
||||||
bool containsImpl(const KeyType& key) {
|
bool containsImpl(const T& 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 KeyType& key) {
|
bool removeImpl(const T& key) {
|
||||||
return (self->erase(key) > 0);
|
return (self->erase(key) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,4 +192,4 @@ class unordered_set {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace std
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue