File indexing completed on 2024-12-08 11:06:52

0001 //
0002 // C++ Implementation: flowconnectorlist
0003 //
0004 // Description:
0005 //
0006 //
0007 // Author: David Saxton, Alan Grimes, Zoltan Padrah <zoltan.padrah@gmail.com>, (C) 2009
0008 //
0009 // Copyright: See COPYING file that comes with this distribution
0010 //
0011 //
0012 
0013 #include "flowconnectorlist.h"
0014 
0015 #include "flowconnector.h"
0016 
0017 #include <QList>
0018 #include <QPointer>
0019 
0020 FlowConnectorList::FlowConnectorList(const QList<T> &l)
0021     : flowList(l)
0022 { // O(n)
0023     FlowConnectorList::iterator it, end = flowList.end();
0024     for (it = flowList.begin(); it != end; it++)
0025         list.append(CAST_POINTER_CONN(* it));
0026 }
0027 
0028 // FlowConnectorList::FlowConnectorList ( const std::list<FlowConnectorList::T> & l ) : flowList(l) {
0029 //     FlowConnectorList::iterator it, end = flowList.end();
0030 //     for( it = flowList.begin(); it != end; it++)
0031 //         list.append( CAST_POINTER *it);
0032 // }
0033 
0034 QList<FlowConnectorList::T> &FlowConnectorList::operator=(const QList<FlowConnectorList::T> &l)
0035 { // -> O(n)
0036     flowList = l;
0037     list.clear();
0038     FlowConnectorList::iterator it, end = flowList.end();
0039     for (it = flowList.begin(); it != end; it++)
0040         list.append(CAST_POINTER_CONN(* it));
0041     return flowList;
0042 }
0043 
0044 // QList<FlowConnectorList::T> & FlowConnectorList::operator= ( const std::list<FlowConnectorList::T> & l ) {   // O(n)
0045 //     flowList = l;
0046 //     list.clear();
0047 //     FlowConnectorList::iterator it, end = flowList.end();
0048 //     for( it = flowList.begin(); it != end; it++)
0049 //         list.append( CAST_POINTER *it);
0050 //
0051 //     return flowList;
0052 // }
0053 
0054 // bool FlowConnectorList::operator== ( const std::list<FlowConnectorList::T> & l ) const {
0055 //     return flowList == l;
0056 // }
0057 
0058 FlowConnectorList::iterator FlowConnectorList::insert(FlowConnectorList::iterator it, const FlowConnectorList::T &x)
0059 { // O(n)
0060     list.insert(convertIterator(it), CAST_POINTER_CONN(x));
0061     return flowList.insert(it, x);
0062 }
0063 
0064 uint FlowConnectorList::remove(const FlowConnectorList::T &x)
0065 {
0066     list.removeAll(CAST_POINTER_CONN(x));
0067     return flowList.removeAll(x);
0068 }
0069 
0070 QList<FlowConnectorList::T> &FlowConnectorList::operator<<(const FlowConnectorList::T &x)
0071 {
0072     list << CAST_POINTER_CONN(x);
0073     return flowList << x;
0074 }
0075 
0076 void FlowConnectorList::push_front(const FlowConnectorList::T &x)
0077 {
0078     list.push_front(CAST_POINTER_CONN(x));
0079     flowList.push_front(x);
0080 }
0081 
0082 void FlowConnectorList::push_back(const FlowConnectorList::T &x)
0083 {
0084     list.push_back(CAST_POINTER_CONN(x));
0085     flowList.push_back(x);
0086 }
0087 
0088 // void FlowConnectorList::insert ( FlowConnectorList::iterator pos, size_type n, const FlowConnectorList::T & x ) {    // O(n)
0089 //     list.insert( convertIterator(pos) ,n, CAST_POINTER x);
0090 //     flowList.insert(pos,n,x);
0091 // }
0092 
0093 QList<FlowConnectorList::T> &FlowConnectorList::operator+=(const QList<FlowConnectorList::T> &l)
0094 { // O(n)
0095     const_iterator end = l.end();
0096     for (const_iterator it = l.begin(); it != end; it++)
0097         list.append(CAST_POINTER_CONN(* it));
0098     return flowList += l;
0099 }
0100 
0101 // FlowConnectorList::iterator FlowConnectorList::fromLast () {
0102 //     return flowList.fromLast();
0103 // }
0104 
0105 FlowConnectorList::iterator FlowConnectorList::append(const FlowConnectorList::T &x)
0106 {
0107     list.append(CAST_POINTER_CONN(x));
0108     // return flowList.append(x);
0109     flowList.append(x);
0110     iterator ret = flowList.end();
0111     --ret;
0112     return ret;
0113 }
0114 
0115 FlowConnectorList::iterator FlowConnectorList::prepend(const FlowConnectorList::T &x)
0116 {
0117     list.prepend(CAST_POINTER_CONN(x));
0118     // return flowList.prepend(x);
0119     flowList.prepend(x);
0120     return flowList.begin();
0121 }
0122 
0123 QList<FlowConnectorList::T> &FlowConnectorList::operator+=(const FlowConnectorList::T &x)
0124 {
0125     list += CAST_POINTER_CONN(x);
0126     return flowList += x;
0127 }
0128 
0129 // FlowConnectorList::const_iterator FlowConnectorList::fromLast () const {
0130 //     return flowList.fromLast();
0131 // }