Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Add empty to STL_VECTOR_COMPATIBILITY
Add empty to STL_VECTOR_COMPATIBILITY [message #33240] Tue, 19 July 2011 16:24 Go to next message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
I am having troubles using Vector as a base for priority_queue because it lack and empty method:
#define STL_VECTOR_COMPATIBILITY(C) \
	typedef T             value_type; \
	typedef ConstIterator const_iterator; \
	typedef const T&      const_reference; \
	typedef int           size_type; \
	typedef int           difference_type; \
	const_iterator        begin() const          { return Begin(); } \
	const_iterator        end() const            { return End(); } \
	void                  clear()                { Clear(); } \
	size_type             size()                 { return GetCount(); } \
	typedef Iterator      iterator; \
	typedef T&            reference; \
	iterator              begin()                { return Begin(); } \
	iterator              end()                  { return End(); } \
	reference             front()                { return (*this)[0]; } \
	const_reference       front() const          { return (*this)[0]; } \
	reference             back()                 { return Top(); } \
	const_reference       back() const           { return Top(); } \
	void                  push_back(const T& x)  { Add(x); } \
	void                  pop_back()             { Drop(); } \
	bool                  empty() const          { return IsEmpty(); }


PS: Is there an U++ alternative to priority_queue that is at least as fast?
Re: Add empty to STL_VECTOR_COMPATIBILITY [message #33272 is a reply to message #33240] Thu, 21 July 2011 19:18 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Applied.

Mirek
Re: Add empty to STL_VECTOR_COMPATIBILITY [message #33276 is a reply to message #33272] Fri, 22 July 2011 09:18 Go to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Thanks!

I am not sure about the rest of containers, but in this case I guess it is better to go on a need by need basis.
Previous Topic: [PROPOSAL] U++ version macro
Next Topic: Bugs in Tuple, RemoveSorted and in Scribble Example
Goto Forum:
  


Current Time: Sun Apr 28 14:39:26 CEST 2024

Total time taken to generate the page: 0.02969 seconds