mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-11 17:03:59 +00:00
@@ -15,8 +15,8 @@ public:
|
||||
iterator erase(const iterator& item);
|
||||
|
||||
private:
|
||||
class node;
|
||||
node* erase(const node* item);
|
||||
struct node;
|
||||
node* erase(node* item);
|
||||
|
||||
public:
|
||||
list()
|
||||
@@ -33,18 +33,22 @@ public:
|
||||
size_t size() const { return x14_count; }
|
||||
bool empty() const { return x14_count == 0; }
|
||||
|
||||
void pop_front() {
|
||||
erase(x4_start);
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(x4_start); }
|
||||
const_iterator begin() const { return const_iterator(x4_start); }
|
||||
iterator end() { return iterator(x8_end); }
|
||||
const_iterator end() const { return const_iterator(x8_end); }
|
||||
|
||||
iterator erase(const iterator& start, const iterator& end) {
|
||||
iterator it = start;
|
||||
while (it != end) {
|
||||
erase(it++);
|
||||
node* last = end.get_node();
|
||||
node* it = start.get_node();
|
||||
while (it != last) {
|
||||
it = erase(it);
|
||||
}
|
||||
|
||||
return it;
|
||||
return iterator(it);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -135,6 +139,8 @@ public:
|
||||
bool operator==(const iterator& other) const { return current == other.current; }
|
||||
bool operator!=(const iterator& other) const { return current != other.current; }
|
||||
|
||||
node* get_node() const { return current; }
|
||||
|
||||
protected:
|
||||
node* current;
|
||||
};
|
||||
@@ -160,6 +166,21 @@ list< T, Alloc >::~list() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template < typename T, typename Alloc >
|
||||
typename list< T, Alloc >::node* list< T, Alloc >::erase(node* node) {
|
||||
typename list< T, Alloc >::node* result = node->get_next();
|
||||
if (node == x4_start) {
|
||||
x4_start = result;
|
||||
}
|
||||
node->get_prev()->set_next(node->get_next());
|
||||
node->get_next()->set_prev(node->get_prev());
|
||||
destroy(node);
|
||||
x0_allocator.deallocate(node);
|
||||
x14_count--;
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace rstl
|
||||
|
||||
#endif // _RSTL_LIST
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
template < typename T >
|
||||
class rc_ptr {
|
||||
public:
|
||||
rc_ptr() : x0_refData(&CRefData::sNull) { x0_refData->AddRef(); }
|
||||
rc_ptr(const T* ptr) : x0_refData(new CRefData(ptr)) {}
|
||||
rc_ptr(const rc_ptr& other) : x0_refData(other.x0_refData) { x0_refData->AddRef(); }
|
||||
~rc_ptr() { ReleaseData(); }
|
||||
@@ -47,8 +48,16 @@ void rc_ptr< T >::ReleaseData() {
|
||||
template < typename T >
|
||||
class ncrc_ptr : public rc_ptr< T > {
|
||||
public:
|
||||
ncrc_ptr() {}
|
||||
ncrc_ptr(T* ptr) : rc_ptr< T >(ptr) {}
|
||||
ncrc_ptr(const rc_ptr< T >& other) : rc_ptr< T >(other) {}
|
||||
};
|
||||
|
||||
template < typename T >
|
||||
bool operator==(const rc_ptr< T >& left, const rc_ptr< T >& right) {
|
||||
return left.GetPtr() == right.GetPtr();
|
||||
}
|
||||
|
||||
} // namespace rstl
|
||||
|
||||
#endif // _RSTL_RC_PTR
|
||||
|
||||
@@ -105,9 +105,17 @@ public:
|
||||
}
|
||||
basic_string operator+(const _CharTp*);
|
||||
|
||||
int _eq_helper(const basic_string& other) const;
|
||||
bool operator==(const basic_string& other) const;
|
||||
|
||||
const char* data() const { return x0_ptr; }
|
||||
};
|
||||
|
||||
template < typename _CharTp, typename Traits, typename Alloc >
|
||||
bool basic_string< _CharTp, Traits, Alloc >::operator==(const basic_string& other) const {
|
||||
return _eq_helper(other) == 0;
|
||||
}
|
||||
|
||||
// template <>
|
||||
// const char basic_string<char>::mNull = 0;
|
||||
// template <>
|
||||
|
||||
Reference in New Issue
Block a user