Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
ilist.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/impl/ItemEventHandler.h"
19#include "hazelcast/client/proxy/IListImpl.h"
20#include "hazelcast/client/protocol/codec/codecs.h"
21
22namespace hazelcast {
23namespace client {
28class ilist : public proxy::IListImpl
29{
30 friend class spi::ProxyManager;
31
32public:
33 static constexpr const char* SERVICE_NAME = "hz:impl:listService";
34
47 boost::future<boost::uuids::uuid> add_item_listener(
48 item_listener&& listener,
49 bool include_value)
50 {
51 std::unique_ptr<
52 impl::item_event_handler<protocol::codec::list_addlistener_handler>>
53 itemEventHandler(new impl::item_event_handler<
54 protocol::codec::list_addlistener_handler>(
55 get_name(),
56 get_context().get_logger(),
57 get_context().get_client_cluster_service(),
58 get_context().get_serialization_service(),
59 std::move(listener),
60 include_value));
61
62 return proxy::IListImpl::add_item_listener(std::move(itemEventHandler),
63 include_value);
64 }
65
71 template<typename E>
72 boost::future<bool> contains(const E& element)
73 {
74 return proxy::IListImpl::contains(to_data(element));
75 }
76
81 template<typename E>
82 boost::future<std::vector<E>> to_array()
83 {
84 return to_object_vector<E>(proxy::IListImpl::to_array_data());
85 }
86
92 template<typename E>
93 boost::future<bool> add(const E& element)
94 {
95 return proxy::IListImpl::add(to_data(element));
96 }
97
103 template<typename E>
104 boost::future<bool> remove(const E& element)
105 {
106 return proxy::IListImpl::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::IListImpl::contains_all_data(
118 to_data_collection(elements));
119 }
120
126 template<typename E>
127 boost::future<bool> add_all(const std::vector<E>& elements)
128 {
129 return proxy::IListImpl::add_all_data(to_data_collection(elements));
130 }
131
142 template<typename E>
143 boost::future<bool> add_all(int32_t index, const std::vector<E>& elements)
144 {
145 return proxy::IListImpl::add_all_data(index,
146 to_data_collection(elements));
147 }
148
154 template<typename E>
155 boost::future<bool> remove_all(const std::vector<E>& elements)
156 {
157 return proxy::IListImpl::remove_all_data(to_data_collection(elements));
158 }
159
167 template<typename E>
168 boost::future<bool> retain_all(const std::vector<E>& elements)
169 {
170 return proxy::IListImpl::retain_all_data(to_data_collection(elements));
171 }
172
186 template<typename E>
187 boost::future<boost::optional<E>> get(int32_t index)
188 {
189 return to_object<E>(proxy::IListImpl::get_data(index));
190 }
191
203 template<typename E, typename R = E>
204 boost::future<boost::optional<R>> set(int32_t index, const E& element)
205 {
206 return to_object<R>(
207 proxy::IListImpl::set_data(index, to_data(element)));
208 }
209
219 template<typename E>
220 boost::future<void> add(int32_t index, const E& element)
221 {
222 return proxy::IListImpl::add(index, to_data(element));
223 }
224
233 template<typename E>
234 boost::future<boost::optional<E>> remove(int32_t index)
235 {
236 return to_object<E>(proxy::IListImpl::remove_data(index));
237 }
238
245 template<typename E>
246 boost::future<int> index_of(const E& element)
247 {
248 return proxy::IListImpl::index_of(to_data(element));
249 }
250
256 template<typename E>
257 boost::future<int32_t> last_index_of(const E& element)
258 {
259 return proxy::IListImpl::last_index_of(to_data(element));
260 }
261
267 template<typename E>
268 boost::future<std::vector<E>> sub_list(int32_t from_index, int32_t to_index)
269 {
270 return to_object_vector<E>(
271 proxy::IListImpl::sub_list_data(from_index, to_index));
272 }
273
274private:
275 ilist(const std::string& instance_name, spi::ClientContext* context)
276 : proxy::IListImpl(instance_name, context)
277 {}
278};
279} // namespace client
280} // namespace hazelcast
Concurrent, distributed, client implementation of list.
Definition ilist.h:29
boost::future< bool > contains(const E &element)
Definition ilist.h:72
boost::future< bool > add_all(const std::vector< E > &elements)
Definition ilist.h:127
boost::future< boost::optional< R > > set(int32_t index, const E &element)
Replaced the element in the given index.
Definition ilist.h:204
boost::future< boost::optional< E > > get(int32_t index)
You can check if element is available by.
Definition ilist.h:187
boost::future< std::vector< E > > sub_list(int32_t from_index, int32_t to_index)
Definition ilist.h:268
boost::future< bool > retain_all(const std::vector< E > &elements)
Removes the elements from this list that are not available in given "elements" vector.
Definition ilist.h:168
boost::future< boost::optional< E > > remove(int32_t index)
Definition ilist.h:234
boost::future< bool > add(const E &element)
Definition ilist.h:93
boost::future< bool > remove(const E &element)
Definition ilist.h:104
boost::future< void > add(int32_t index, const E &element)
Adds the element to the given index.
Definition ilist.h:220
boost::future< std::vector< E > > to_array()
Definition ilist.h:82
boost::future< int > index_of(const E &element)
Definition ilist.h:246
boost::future< bool > remove_all(const std::vector< E > &elements)
Definition ilist.h:155
boost::future< bool > contains_all(const std::vector< E > &elements)
Definition ilist.h:115
boost::future< int32_t > last_index_of(const E &element)
Definition ilist.h:257
boost::future< bool > add_all(int32_t index, const std::vector< E > &elements)
Adds elements in vector to the list with given order.
Definition ilist.h:143
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 ilist.h:47
Item listener for IQueue, ISet and IList.