From e645fc2693acc796304498909786b7b47005b429 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Mon, 23 Jan 2012 08:53:35 +0100 Subject: Imported Upstream version 2.1.3 --- src/yarray.hpp | 110 --------------------------------------------------------- 1 file changed, 110 deletions(-) delete mode 100644 src/yarray.hpp (limited to 'src/yarray.hpp') diff --git a/src/yarray.hpp b/src/yarray.hpp deleted file mode 100644 index 8c79b99..0000000 --- a/src/yarray.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (c) 2007-2010 iMatix Corporation - - This file is part of 0MQ. - - 0MQ is free software; you can redistribute it and/or modify it under - the terms of the Lesser GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - 0MQ is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - Lesser GNU General Public License for more details. - - You should have received a copy of the Lesser GNU General Public License - along with this program. If not, see . -*/ - -#ifndef __ZMQ_YARRAY_INCLUDED__ -#define __ZMQ_YARRAY_INCLUDED__ - -#include -#include - -namespace zmq -{ - - // Fast array implementation with O(1) access to item, insertion and - // removal. Yarray stores pointers rather than objects. The objects have - // to be derived from yarray_item_t class. - - template class yarray_t - { - public: - - typedef typename std::vector ::size_type size_type; - - inline yarray_t () - { - } - - inline ~yarray_t () - { - } - - inline size_type size () - { - return items.size (); - } - - inline bool empty () - { - return items.empty (); - } - - inline T *&operator [] (size_type index_) - { - return items [index_]; - } - - inline void push_back (T *item_) - { - if (item_) - item_->set_yarray_index (items.size ()); - items.push_back (item_); - } - - inline void erase (T *item_) { - erase (item_->get_yarray_index ()); - } - - inline void erase (size_type index_) { - if (items.back ()) - items.back ()->set_yarray_index (index_); - items [index_] = items.back (); - items.pop_back (); - } - - inline void swap (size_type index1_, size_type index2_) - { - if (items [index1_]) - items [index1_]->set_yarray_index (index2_); - if (items [index2_]) - items [index2_]->set_yarray_index (index1_); - std::swap (items [index1_], items [index2_]); - } - - inline void clear () - { - items.clear (); - } - - inline size_type index (T *item_) - { - return (size_type) item_->get_yarray_index (); - } - - private: - - typedef std::vector items_t; - items_t items; - - yarray_t (const yarray_t&); - void operator = (const yarray_t&); - }; - -} - -#endif -- cgit v1.2.3