add sort_filename

This commit is contained in:
David Rose 2005-05-23 22:30:26 +00:00
parent ed058d20ad
commit d122e0084b
3 changed files with 23 additions and 0 deletions

View File

@ -46,6 +46,14 @@ PUBLISHED:
INLINE const Filename &get_fullpath() const;
INLINE void set_fullpath(const Filename &fullpath);
public:
class IndirectOrderByBasename {
public:
bool operator () (const EggFilenameNode *a, const EggFilenameNode *b) const {
return a->get_filename().get_basename() < b->get_filename().get_basename();
}
};
private:
Filename _filename;
Filename _fullpath;

View File

@ -421,6 +421,20 @@ sort_by_tref() {
NamableOrderByName());
}
////////////////////////////////////////////////////////////////////
// Function: EggTextureCollection::sort_by_basename
// Access: Public
// Description: Sorts all the textures into alphabetical order by
// the basename part (including extension) of the
// filename. Subsequent operations using begin()/end()
// will traverse in this sorted order.
////////////////////////////////////////////////////////////////////
void EggTextureCollection::
sort_by_basename() {
sort(_ordered_textures.begin(), _ordered_textures.end(),
EggFilenameNode::IndirectOrderByBasename());
}
////////////////////////////////////////////////////////////////////
// Function: EggTextureCollection::add_texture
// Access: Public

View File

@ -83,6 +83,7 @@ PUBLISHED:
void uniquify_trefs();
void sort_by_tref();
void sort_by_basename();
public:
// Can be used to traverse all the textures in the collection, in