Hazelcast C++ Client
Hazelcast C++ Client Library
iset.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include "hazelcast/client/proxy/ISetImpl.h"
19 #include "hazelcast/client/impl/ItemEventHandler.h"
20 #include "hazelcast/client/protocol/codec/codecs.h"
21 
22 namespace hazelcast {
23  namespace client {
28  class HAZELCAST_API iset : public proxy::ISetImpl {
29  friend class spi::ProxyManager;
30  public:
31  static constexpr const char *SERVICE_NAME = "hz:impl:setService";
32 
43  boost::future<boost::uuids::uuid> add_item_listener(item_listener &&listener, bool include_value) {
44  std::unique_ptr<impl::item_event_handler<protocol::codec::set_addlistener_handler>> itemEventHandler(
45  new impl::item_event_handler<protocol::codec::set_addlistener_handler>(
46  get_name(), get_context().get_client_cluster_service(),
47  get_context().get_serialization_service(),
48  std::move(listener),
49  include_value));
50 
51  return proxy::ISetImpl::add_item_listener(std::move(itemEventHandler), include_value);
52  }
53 
59  template<typename E>
60  boost::future<bool> contains(const E &element) {
61  return proxy::ISetImpl::contains(to_data(element));
62  }
63 
68  template<typename E>
69  boost::future<std::vector<E>> to_array() {
70  return to_object_vector<E>(proxy::ISetImpl::to_array_data());
71  }
72 
78  template<typename E>
79  boost::future<bool> add(const E &element) {
80  return proxy::ISetImpl::add(to_data(element));
81  }
82 
88  template<typename E>
89  boost::future<bool> remove(const E &element) {
90  return proxy::ISetImpl::remove(to_data(element));
91  }
92 
98  template<typename E>
99  boost::future<bool> contains_all(const std::vector<E> &elements) {
100  return proxy::ISetImpl::contains_all(to_data_collection(elements));
101  }
102 
108  template<typename E>
109  boost::future<bool> add_all(const std::vector<E> &elements) {
110  std::vector<serialization::pimpl::data> dataCollection = to_data_collection(elements);
111  return proxy::ISetImpl::add_all(to_data_collection(elements));
112  }
113 
119  template<typename E>
120  boost::future<bool> remove_all(const std::vector<E> &elements) {
121  return proxy::ISetImpl::remove_all(to_data_collection(elements));
122  }
123 
130  template<typename E>
131  boost::future<bool> retain_all(const std::vector<E> &elements) {
132  return proxy::ISetImpl::retain_all(to_data_collection(elements));
133  }
134 
135  private:
136  iset(const std::string &instance_name, spi::ClientContext *context)
137  : proxy::ISetImpl(instance_name, context) {}
138  };
139  }
140 }
141 
Concurrent, distributed client implementation of std::unordered_set.
Definition: iset.h:28
boost::future< std::vector< E > > to_array()
Definition: iset.h:69
boost::future< bool > retain_all(const std::vector< E > &elements)
Removes the elements from this set that are not available in given "elements" vector.
Definition: iset.h:131
boost::future< bool > add(const E &element)
Definition: iset.h:79
boost::future< boost::uuids::uuid > add_item_listener(item_listener &&listener, bool include_value)
Warning 1: If listener should do a time consuming operation, off-load the operation to another thread...
Definition: iset.h:43
boost::future< bool > contains_all(const std::vector< E > &elements)
Definition: iset.h:99
boost::future< bool > remove(const E &element)
Definition: iset.h:89
boost::future< bool > contains(const E &element)
Definition: iset.h:60
boost::future< bool > remove_all(const std::vector< E > &elements)
Definition: iset.h:120
boost::future< bool > add_all(const std::vector< E > &elements)
Definition: iset.h:109
Item listener for IQueue, ISet and IList.
Definition: item_listener.h:51