Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
iset.h
1/*
2 * Copyright (c) 2008-2025, 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
22namespace hazelcast {
23namespace client {
28class HAZELCAST_API iset : public proxy::ISetImpl
29{
30 friend class spi::ProxyManager;
31
32public:
33 static constexpr const char* SERVICE_NAME = "hz:impl:setService";
34
46 boost::future<boost::uuids::uuid> add_item_listener(
47 item_listener&& listener,
48 bool include_value)
49 {
50 std::unique_ptr<
51 impl::item_event_handler<protocol::codec::set_addlistener_handler>>
52 itemEventHandler(new impl::item_event_handler<
53 protocol::codec::set_addlistener_handler>(
54 get_name(),
55 get_context().get_logger(),
56 get_context().get_client_cluster_service(),
57 get_context().get_serialization_service(),
58 std::move(listener),
59 include_value));
60
61 return proxy::ISetImpl::add_item_listener(std::move(itemEventHandler),
62 include_value);
63 }
64
70 template<typename E>
71 boost::future<bool> contains(const E& element)
72 {
73 return proxy::ISetImpl::contains(to_data(element));
74 }
75
80 template<typename E>
81 boost::future<std::vector<E>> to_array()
82 {
83 return to_object_vector<E>(proxy::ISetImpl::to_array_data());
84 }
85
92 template<typename E>
93 boost::future<bool> add(const E& element)
94 {
95 return proxy::ISetImpl::add(to_data(element));
96 }
97
103 template<typename E>
104 boost::future<bool> remove(const E& element)
105 {
106 return proxy::ISetImpl::remove(to_data(element));
107 }
108
114 template<typename E>
115 boost::future<bool> contains_all(const std::vector<E>& elements)
116 {
117 return proxy::ISetImpl::contains_all(to_data_collection(elements));
118 }
119
125 template<typename E>
126 boost::future<bool> add_all(const std::vector<E>& elements)
127 {
128 std::vector<serialization::pimpl::data> dataCollection =
129 to_data_collection(elements);
130 return proxy::ISetImpl::add_all(to_data_collection(elements));
131 }
132
138 template<typename E>
139 boost::future<bool> remove_all(const std::vector<E>& elements)
140 {
141 return proxy::ISetImpl::remove_all(to_data_collection(elements));
142 }
143
151 template<typename E>
152 boost::future<bool> retain_all(const std::vector<E>& elements)
153 {
154 return proxy::ISetImpl::retain_all(to_data_collection(elements));
155 }
156
157private:
158 iset(const std::string& instance_name, spi::ClientContext* context)
159 : proxy::ISetImpl(instance_name, context)
160 {}
161};
162} // namespace client
163} // namespace hazelcast
Concurrent, distributed client implementation of std::unordered_set.
Definition iset.h:29
boost::future< bool > remove(const E &element)
Definition iset.h:104
boost::future< std::vector< E > > to_array()
Definition iset.h:81
boost::future< bool > add_all(const std::vector< E > &elements)
Definition iset.h:126
boost::future< bool > remove_all(const std::vector< E > &elements)
Definition iset.h:139
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:46
boost::future< bool > contains(const E &element)
Definition iset.h:71
boost::future< bool > add(const E &element)
Definition iset.h:93
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:152
boost::future< bool > contains_all(const std::vector< E > &elements)
Definition iset.h:115
Item listener for IQueue, ISet and IList.