Switch lists of pointers to vectors of pointers

This commit is contained in:
Thomas Goyne 2012-11-28 07:46:33 -08:00
parent e77e810bd8
commit 7a7a036017
7 changed files with 17 additions and 15 deletions

View file

@ -69,10 +69,11 @@ void AssExportFilterChain::Register(AssExportFilter *filter) {
} }
void AssExportFilterChain::Unregister(AssExportFilter *filter) { void AssExportFilterChain::Unregister(AssExportFilter *filter) {
if (find(filters()->begin(), filters()->end(), filter) == filters()->end()) auto it = remove(begin(*filters()), end(*filters()), filter);
if (it == end(*filters()))
throw wxString::Format("Unregister export filter: name \"%s\" is not registered.", filter->name); throw wxString::Format("Unregister export filter: name \"%s\" is not registered.", filter->name);
filters()->remove(filter); filters()->pop_back();
} }
FilterList *AssExportFilterChain::filters() { FilterList *AssExportFilterChain::filters() {

View file

@ -35,8 +35,8 @@
#pragma once #pragma once
#ifndef AGI_PRE #ifndef AGI_PRE
#include <list>
#include <memory> #include <memory>
#include <vector>
#include <wx/string.h> #include <wx/string.h>
#include <wx/window.h> #include <wx/window.h>
@ -47,8 +47,7 @@ class AssExportFilter;
namespace agi { struct Context; } namespace agi { struct Context; }
/// DOCME typedef std::vector<AssExportFilter*> FilterList;
typedef std::list<AssExportFilter*> FilterList;
/// DOCME /// DOCME
/// @class AssExportFilterChain /// @class AssExportFilterChain

View file

@ -45,11 +45,11 @@
#include <algorithm> #include <algorithm>
#endif #endif
static inline std::list<AssExportFilter*>::const_iterator filter_list_begin() { static inline FilterList::const_iterator filter_list_begin() {
return AssExportFilterChain::GetFilterList()->begin(); return AssExportFilterChain::GetFilterList()->begin();
} }
static inline std::list<AssExportFilter*>::const_iterator filter_list_end() { static inline FilterList::const_iterator filter_list_end() {
return AssExportFilterChain::GetFilterList()->end(); return AssExportFilterChain::GetFilterList()->end();
} }

View file

@ -37,15 +37,15 @@
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/string.h> #include <wx/string.h>
#include <list>
#include <map> #include <map>
#include <vector>
#endif #endif
class AssExportFilter; class AssExportFilter;
class AssFile; class AssFile;
namespace agi { struct Context; } namespace agi { struct Context; }
typedef std::list<AssExportFilter*> FilterList; typedef std::vector<AssExportFilter*> FilterList;
/// DOCME /// DOCME
/// @class AssExporter /// @class AssExporter

View file

@ -401,9 +401,10 @@ void DialogStyleManager::OnCatalogDelete() {
} }
void DialogStyleManager::OnCopyToStorage() { void DialogStyleManager::OnCopyToStorage() {
std::list<wxString> copied;
wxArrayInt selections; wxArrayInt selections;
int n = CurrentList->GetSelections(selections); int n = CurrentList->GetSelections(selections);
wxArrayString copied;
copied.reserve(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
wxString styleName = CurrentList->GetString(selections[i]); wxString styleName = CurrentList->GetString(selections[i]);
@ -427,9 +428,10 @@ void DialogStyleManager::OnCopyToStorage() {
} }
void DialogStyleManager::OnCopyToCurrent() { void DialogStyleManager::OnCopyToCurrent() {
std::list<wxString> copied;
wxArrayInt selections; wxArrayInt selections;
int n = StorageList->GetSelections(selections); int n = StorageList->GetSelections(selections);
wxArrayString copied;
copied.reserve(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
wxString styleName = StorageList->GetString(selections[i]); wxString styleName = StorageList->GetString(selections[i]);
bool addStyle = true; bool addStyle = true;

View file

@ -68,7 +68,7 @@ SubtitleFormat::SubtitleFormat(wxString const& name)
} }
SubtitleFormat::~SubtitleFormat() { SubtitleFormat::~SubtitleFormat() {
formats.remove(this); formats.erase(remove(begin(formats), end(formats), this));
} }
bool SubtitleFormat::CanReadFile(wxString const& filename) const { bool SubtitleFormat::CanReadFile(wxString const& filename) const {
@ -301,7 +301,7 @@ void SubtitleFormat::MergeIdentical(AssFile &file) {
} }
} }
std::list<SubtitleFormat*> SubtitleFormat::formats; std::vector<SubtitleFormat*> SubtitleFormat::formats;
void SubtitleFormat::LoadFormats() { void SubtitleFormat::LoadFormats() {
if (formats.empty()) { if (formats.empty()) {

View file

@ -35,7 +35,7 @@
#pragma once #pragma once
#ifndef AGI_PRE #ifndef AGI_PRE
#include <list> #include <vector>
#include <wx/arrstr.h> #include <wx/arrstr.h>
#include <wx/string.h> #include <wx/string.h>
@ -61,7 +61,7 @@ class SubtitleFormat {
virtual wxArrayString GetWriteWildcards() const { return wxArrayString(); } virtual wxArrayString GetWriteWildcards() const { return wxArrayString(); }
/// List of loaded subtitle formats /// List of loaded subtitle formats
static std::list<SubtitleFormat*> formats; static std::vector<SubtitleFormat*> formats;
public: public:
/// Strip override tags /// Strip override tags