mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:27:45 +00:00
Everywhere: "indexes" => "indices"
I've wasted a silly amount of time in the past fretting over which of these words to use. Let's just choose one and use it everywhere. :^)
This commit is contained in:
parent
7ae7170d61
commit
3d4afe7614
29 changed files with 139 additions and 139 deletions
|
@ -67,7 +67,7 @@ typedef uint32_t Elf64_Half;
|
|||
typedef uint16_t Elf64_Quarter;
|
||||
|
||||
/*
|
||||
* e_ident[] identification indexes
|
||||
* e_ident[] identification indices
|
||||
* See http://www.sco.com/developers/gabi/latest/ch4.eheader.html
|
||||
*/
|
||||
#define EI_MAG0 0 /* file ID */
|
||||
|
@ -241,15 +241,15 @@ typedef struct {
|
|||
Elf64_Xword sh_entsize; /* table entry size */
|
||||
} Elf64_Shdr;
|
||||
|
||||
/* Special Section Indexes */
|
||||
/* Special Section Indices */
|
||||
#define SHN_UNDEF 0 /* undefined */
|
||||
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
|
||||
#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indices */
|
||||
#define SHN_LOPROC 0xff00 /* reserved range for processor */
|
||||
#define SHN_HIPROC 0xff1f /* specific section indexes */
|
||||
#define SHN_HIPROC 0xff1f /* specific section indices */
|
||||
#define SHN_ABS 0xfff1 /* absolute value */
|
||||
#define SHN_COMMON 0xfff2 /* common symbol */
|
||||
#define SHN_XINDEX 0xffff /* Escape -- index stored elsewhere. */
|
||||
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
|
||||
#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indices */
|
||||
|
||||
/* sh_type */
|
||||
#define SHT_NULL 0 /* inactive */
|
||||
|
@ -269,7 +269,7 @@ typedef struct {
|
|||
#define SHT_FINI_ARRAY 15 /* pointers to termination functions */
|
||||
#define SHT_PREINIT_ARRAY 16 /* ptrs to funcs called before init */
|
||||
#define SHT_GROUP 17 /* defines a section group */
|
||||
#define SHT_SYMTAB_SHNDX 18 /* Section indexes (see SHN_XINDEX). */
|
||||
#define SHT_SYMTAB_SHNDX 18 /* Section indices (see SHN_XINDEX). */
|
||||
#define SHT_LOOS 0x60000000 /* reserved range for OS specific */
|
||||
#define SHT_SUNW_dof 0x6ffffff4 /* used by dtrace */
|
||||
#define SHT_GNU_LIBLIST 0x6ffffff7 /* libraries to be prelinked */
|
||||
|
@ -282,7 +282,7 @@ typedef struct {
|
|||
#define SHT_LOPROC 0x70000000 /* reserved range for processor */
|
||||
#define SHT_HIPROC 0x7fffffff /* specific section header types */
|
||||
#define SHT_LOUSER 0x80000000 /* reserved range for application */
|
||||
#define SHT_HIUSER 0xffffffff /* specific indexes */
|
||||
#define SHT_HIUSER 0xffffffff /* specific indices */
|
||||
|
||||
#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table section */
|
||||
|
||||
|
|
|
@ -578,7 +578,7 @@ FLATTEN void UnsignedBigInteger::shift_left_without_allocation(
|
|||
* Complexity: O(N^2) where N is the number of words in the larger number
|
||||
* Multiplication method:
|
||||
* An integer is equal to the sum of the powers of two
|
||||
* according to the indexes of its 'on' bits.
|
||||
* according to the indices of its 'on' bits.
|
||||
* So to multiple x*y, we go over each '1' bit in x (say the i'th bit),
|
||||
* and add y<<i to the result.
|
||||
*/
|
||||
|
|
|
@ -43,13 +43,13 @@ void AbstractView::set_model(RefPtr<Model> model)
|
|||
m_model = move(model);
|
||||
if (m_model)
|
||||
m_model->register_view({}, *this);
|
||||
model_did_update(GUI::Model::InvalidateAllIndexes);
|
||||
model_did_update(GUI::Model::InvalidateAllIndices);
|
||||
scroll_to_top();
|
||||
}
|
||||
|
||||
void AbstractView::model_did_update(unsigned int flags)
|
||||
{
|
||||
if (!model() || (flags & GUI::Model::InvalidateAllIndexes)) {
|
||||
if (!model() || (flags & GUI::Model::InvalidateAllIndices)) {
|
||||
stop_editing();
|
||||
m_edit_index = {};
|
||||
m_hovered_index = {};
|
||||
|
@ -630,9 +630,9 @@ void AbstractView::do_search(String&& searching)
|
|||
return;
|
||||
}
|
||||
|
||||
auto found_indexes = model()->matches(searching, Model::MatchesFlag::FirstMatchOnly | Model::MatchesFlag::MatchAtStart | Model::MatchesFlag::CaseInsensitive, model()->parent_index(cursor_index()));
|
||||
if (!found_indexes.is_empty() && found_indexes[0].is_valid()) {
|
||||
auto& index = found_indexes[0];
|
||||
auto found_indices = model()->matches(searching, Model::MatchesFlag::FirstMatchOnly | Model::MatchesFlag::MatchAtStart | Model::MatchesFlag::CaseInsensitive, model()->parent_index(cursor_index()));
|
||||
if (!found_indices.is_empty() && found_indices[0].is_valid()) {
|
||||
auto& index = found_indices[0];
|
||||
m_highlighted_search_index = index;
|
||||
m_searching = move(searching);
|
||||
set_selection(index);
|
||||
|
|
|
@ -629,17 +629,17 @@ Vector<ModelIndex, 1> FileSystemModel::matches(const StringView& searching, unsi
|
|||
{
|
||||
Node& node = const_cast<Node&>(this->node(index));
|
||||
node.reify_if_needed();
|
||||
Vector<ModelIndex, 1> found_indexes;
|
||||
Vector<ModelIndex, 1> found_indices;
|
||||
for (auto& child : node.children) {
|
||||
if (string_matches(child.name, searching, flags)) {
|
||||
const_cast<Node&>(child).reify_if_needed();
|
||||
found_indexes.append(child.index(Column::Name));
|
||||
found_indices.append(child.index(Column::Name));
|
||||
if (flags & FirstMatchOnly)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found_indexes;
|
||||
return found_indices;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -106,10 +106,10 @@ bool FilteringProxyModel::is_searchable() const
|
|||
|
||||
Vector<ModelIndex, 1> FilteringProxyModel::matches(const StringView& searching, unsigned flags, const ModelIndex& index)
|
||||
{
|
||||
auto found_indexes = m_model.matches(searching, flags, index);
|
||||
for (size_t i = 0; i < found_indexes.size(); i++)
|
||||
found_indexes[i] = map(found_indexes[i]);
|
||||
return found_indexes;
|
||||
auto found_indices = m_model.matches(searching, flags, index);
|
||||
for (size_t i = 0; i < found_indices.size(); i++)
|
||||
found_indices[i] = map(found_indices[i]);
|
||||
return found_indices;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ auto IconView::item_data_from_content_position(const Gfx::IntPoint& content_posi
|
|||
void IconView::model_did_update(unsigned flags)
|
||||
{
|
||||
AbstractView::model_did_update(flags);
|
||||
if (!model() || (flags & GUI::Model::InvalidateAllIndexes)) {
|
||||
if (!model() || (flags & GUI::Model::InvalidateAllIndices)) {
|
||||
m_item_data_cache.clear();
|
||||
AbstractView::clear_selection();
|
||||
m_selected_count_cache = 0;
|
||||
|
|
|
@ -37,8 +37,8 @@ public:
|
|||
class Model : public RefCounted<Model> {
|
||||
public:
|
||||
enum UpdateFlag {
|
||||
DontInvalidateIndexes = 0,
|
||||
InvalidateAllIndexes = 1 << 0,
|
||||
DontInvalidateIndices = 0,
|
||||
InvalidateAllIndices = 1 << 0,
|
||||
};
|
||||
|
||||
enum MatchesFlag {
|
||||
|
@ -88,7 +88,7 @@ protected:
|
|||
Model();
|
||||
|
||||
void for_each_view(Function<void(AbstractView&)>);
|
||||
void did_update(unsigned flags = UpdateFlag::InvalidateAllIndexes);
|
||||
void did_update(unsigned flags = UpdateFlag::InvalidateAllIndices);
|
||||
|
||||
static bool string_matches(const StringView& str, const StringView& needle, unsigned flags)
|
||||
{
|
||||
|
|
|
@ -14,13 +14,13 @@ namespace GUI {
|
|||
void ModelSelection::remove_matching(Function<bool(const ModelIndex&)> filter)
|
||||
{
|
||||
Vector<ModelIndex> to_remove;
|
||||
for (auto& index : m_indexes) {
|
||||
for (auto& index : m_indices) {
|
||||
if (filter(index))
|
||||
to_remove.append(index);
|
||||
}
|
||||
if (!to_remove.is_empty()) {
|
||||
for (auto& index : to_remove)
|
||||
m_indexes.remove(index);
|
||||
m_indices.remove(index);
|
||||
notify_selection_changed();
|
||||
}
|
||||
}
|
||||
|
@ -28,19 +28,19 @@ void ModelSelection::remove_matching(Function<bool(const ModelIndex&)> filter)
|
|||
void ModelSelection::set(const ModelIndex& index)
|
||||
{
|
||||
VERIFY(index.is_valid());
|
||||
if (m_indexes.size() == 1 && m_indexes.contains(index))
|
||||
if (m_indices.size() == 1 && m_indices.contains(index))
|
||||
return;
|
||||
m_indexes.clear();
|
||||
m_indexes.set(index);
|
||||
m_indices.clear();
|
||||
m_indices.set(index);
|
||||
notify_selection_changed();
|
||||
}
|
||||
|
||||
void ModelSelection::add(const ModelIndex& index)
|
||||
{
|
||||
VERIFY(index.is_valid());
|
||||
if (m_indexes.contains(index))
|
||||
if (m_indices.contains(index))
|
||||
return;
|
||||
m_indexes.set(index);
|
||||
m_indices.set(index);
|
||||
notify_selection_changed();
|
||||
}
|
||||
|
||||
|
@ -59,28 +59,28 @@ void ModelSelection::add_all(const Vector<ModelIndex>& indices)
|
|||
void ModelSelection::toggle(const ModelIndex& index)
|
||||
{
|
||||
VERIFY(index.is_valid());
|
||||
if (m_indexes.contains(index))
|
||||
m_indexes.remove(index);
|
||||
if (m_indices.contains(index))
|
||||
m_indices.remove(index);
|
||||
else
|
||||
m_indexes.set(index);
|
||||
m_indices.set(index);
|
||||
notify_selection_changed();
|
||||
}
|
||||
|
||||
bool ModelSelection::remove(const ModelIndex& index)
|
||||
{
|
||||
VERIFY(index.is_valid());
|
||||
if (!m_indexes.contains(index))
|
||||
if (!m_indices.contains(index))
|
||||
return false;
|
||||
m_indexes.remove(index);
|
||||
m_indices.remove(index);
|
||||
notify_selection_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ModelSelection::clear()
|
||||
{
|
||||
if (m_indexes.is_empty())
|
||||
if (m_indices.is_empty())
|
||||
return;
|
||||
m_indexes.clear();
|
||||
m_indices.clear();
|
||||
notify_selection_changed();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,12 +25,12 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
int size() const { return m_indexes.size(); }
|
||||
bool is_empty() const { return m_indexes.is_empty(); }
|
||||
bool contains(const ModelIndex& index) const { return m_indexes.contains(index); }
|
||||
int size() const { return m_indices.size(); }
|
||||
bool is_empty() const { return m_indices.is_empty(); }
|
||||
bool contains(const ModelIndex& index) const { return m_indices.contains(index); }
|
||||
bool contains_row(int row) const
|
||||
{
|
||||
for (auto& index : m_indexes) {
|
||||
for (auto& index : m_indices) {
|
||||
if (index.row() == row)
|
||||
return true;
|
||||
}
|
||||
|
@ -47,33 +47,33 @@ public:
|
|||
template<typename Callback>
|
||||
void for_each_index(Callback callback)
|
||||
{
|
||||
for (auto& index : indexes())
|
||||
for (auto& index : indices())
|
||||
callback(index);
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_index(Callback callback) const
|
||||
{
|
||||
for (auto& index : indexes())
|
||||
for (auto& index : indices())
|
||||
callback(index);
|
||||
}
|
||||
|
||||
Vector<ModelIndex> indexes() const
|
||||
Vector<ModelIndex> indices() const
|
||||
{
|
||||
Vector<ModelIndex> selected_indexes;
|
||||
Vector<ModelIndex> selected_indices;
|
||||
|
||||
for (auto& index : m_indexes)
|
||||
selected_indexes.append(index);
|
||||
for (auto& index : m_indices)
|
||||
selected_indices.append(index);
|
||||
|
||||
return selected_indexes;
|
||||
return selected_indices;
|
||||
}
|
||||
|
||||
// FIXME: This doesn't guarantee that what you get is the lowest or "first" index selected..
|
||||
ModelIndex first() const
|
||||
{
|
||||
if (m_indexes.is_empty())
|
||||
if (m_indices.is_empty())
|
||||
return {};
|
||||
return *m_indexes.begin();
|
||||
return *m_indices.begin();
|
||||
}
|
||||
|
||||
void remove_matching(Function<bool(const ModelIndex&)>);
|
||||
|
@ -94,7 +94,7 @@ private:
|
|||
void notify_selection_changed();
|
||||
|
||||
AbstractView& m_view;
|
||||
HashTable<ModelIndex> m_indexes;
|
||||
HashTable<ModelIndex> m_indices;
|
||||
bool m_disable_notify { false };
|
||||
bool m_notify_pending { false };
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ SortingProxyModel::~SortingProxyModel()
|
|||
|
||||
void SortingProxyModel::invalidate(unsigned int flags)
|
||||
{
|
||||
if (flags == UpdateFlag::DontInvalidateIndexes) {
|
||||
if (flags == UpdateFlag::DontInvalidateIndices) {
|
||||
sort(m_last_key_column, m_last_sort_order);
|
||||
} else {
|
||||
m_mappings.clear();
|
||||
|
@ -201,20 +201,20 @@ void SortingProxyModel::sort_mapping(Mapping& mapping, int column, SortOrder sor
|
|||
|
||||
// Update the view's selection.
|
||||
view.selection().change_from_model({}, [&](ModelSelection& selection) {
|
||||
Vector<ModelIndex> selected_indexes_in_source;
|
||||
Vector<ModelIndex> stale_indexes_in_selection;
|
||||
Vector<ModelIndex> selected_indices_in_source;
|
||||
Vector<ModelIndex> stale_indices_in_selection;
|
||||
selection.for_each_index([&](const ModelIndex& index) {
|
||||
if (index.parent() == mapping.source_parent) {
|
||||
stale_indexes_in_selection.append(index);
|
||||
selected_indexes_in_source.append(source().index(old_source_rows[index.row()], index.column(), mapping.source_parent));
|
||||
stale_indices_in_selection.append(index);
|
||||
selected_indices_in_source.append(source().index(old_source_rows[index.row()], index.column(), mapping.source_parent));
|
||||
}
|
||||
});
|
||||
|
||||
for (auto& index : stale_indexes_in_selection) {
|
||||
for (auto& index : stale_indices_in_selection) {
|
||||
selection.remove(index);
|
||||
}
|
||||
|
||||
for (auto& index : selected_indexes_in_source) {
|
||||
for (auto& index : selected_indices_in_source) {
|
||||
for (size_t i = 0; i < mapping.source_rows.size(); ++i) {
|
||||
if (mapping.source_rows[i] == index.row()) {
|
||||
auto new_source_index = this->index(i, index.column(), mapping.source_parent);
|
||||
|
@ -237,7 +237,7 @@ void SortingProxyModel::sort(int column, SortOrder sort_order)
|
|||
m_last_key_column = column;
|
||||
m_last_sort_order = sort_order;
|
||||
|
||||
did_update(UpdateFlag::DontInvalidateIndexes);
|
||||
did_update(UpdateFlag::DontInvalidateIndices);
|
||||
}
|
||||
|
||||
SortingProxyModel::InternalMapIterator SortingProxyModel::build_mapping(const ModelIndex& source_parent)
|
||||
|
@ -287,10 +287,10 @@ bool SortingProxyModel::is_searchable() const
|
|||
|
||||
Vector<ModelIndex, 1> SortingProxyModel::matches(const StringView& searching, unsigned flags, const ModelIndex& proxy_index)
|
||||
{
|
||||
auto found_indexes = source().matches(searching, flags, map_to_source(proxy_index));
|
||||
for (size_t i = 0; i < found_indexes.size(); i++)
|
||||
found_indexes[i] = map_to_proxy(found_indexes[i]);
|
||||
return found_indexes;
|
||||
auto found_indices = source().matches(searching, flags, map_to_source(proxy_index));
|
||||
for (size_t i = 0; i < found_indices.size(); i++)
|
||||
found_indices[i] = map_to_proxy(found_indices[i]);
|
||||
return found_indices;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
private:
|
||||
explicit SortingProxyModel(NonnullRefPtr<Model> source);
|
||||
|
||||
// NOTE: The internal_data() of indexes points to the corresponding Mapping object for that index.
|
||||
// NOTE: The internal_data() of indices points to the corresponding Mapping object for that index.
|
||||
struct Mapping {
|
||||
Vector<int> source_rows;
|
||||
Vector<int> proxy_rows;
|
||||
|
@ -63,7 +63,7 @@ private:
|
|||
Model& source() { return *m_source; }
|
||||
const Model& source() const { return *m_source; }
|
||||
|
||||
void invalidate(unsigned flags = Model::UpdateFlag::DontInvalidateIndexes);
|
||||
void invalidate(unsigned flags = Model::UpdateFlag::DontInvalidateIndices);
|
||||
InternalMapIterator build_mapping(const ModelIndex& proxy_index);
|
||||
|
||||
NonnullRefPtr<Model> m_source;
|
||||
|
|
|
@ -430,10 +430,10 @@ NEVER_INLINE FLATTEN static bool unfilter(PNGLoadingContext& context)
|
|||
auto pixels_per_byte = 8 / context.bit_depth;
|
||||
auto mask = (1 << context.bit_depth) - 1;
|
||||
for (int y = 0; y < context.height; ++y) {
|
||||
auto* palette_indexes = context.scanlines[y].data.data();
|
||||
auto* palette_indices = context.scanlines[y].data.data();
|
||||
for (int i = 0; i < context.width; ++i) {
|
||||
auto bit_offset = (8 - context.bit_depth) - (context.bit_depth * (i % pixels_per_byte));
|
||||
auto palette_index = (palette_indexes[i / pixels_per_byte] >> bit_offset) & mask;
|
||||
auto palette_index = (palette_indices[i / pixels_per_byte] >> bit_offset) & mask;
|
||||
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
|
||||
if ((size_t)palette_index >= context.palette_data.size())
|
||||
return false;
|
||||
|
|
|
@ -79,21 +79,21 @@ describe("normal behavior", () => {
|
|||
}, 100);
|
||||
expect(result).toBe(121);
|
||||
|
||||
var indexes = [];
|
||||
var indices = [];
|
||||
result = ["foo", 1, true].reduce((a, v, i) => {
|
||||
indexes.push(i);
|
||||
indices.push(i);
|
||||
});
|
||||
expect(result).toBeUndefined();
|
||||
expect(indexes.length).toBe(2);
|
||||
expect(indexes[0]).toBe(1);
|
||||
expect(indexes[1]).toBe(2);
|
||||
expect(indices.length).toBe(2);
|
||||
expect(indices[0]).toBe(1);
|
||||
expect(indices[1]).toBe(2);
|
||||
|
||||
indexes = [];
|
||||
indices = [];
|
||||
result = ["foo", 1, true].reduce((a, v, i) => {
|
||||
indexes.push(i);
|
||||
indices.push(i);
|
||||
}, "foo");
|
||||
expect(result).toBeUndefined();
|
||||
expect(indexes).toEqual([0, 1, 2]);
|
||||
expect(indices).toEqual([0, 1, 2]);
|
||||
|
||||
var mutable = { prop: 0 };
|
||||
result = ["foo", 1, true].reduce((a, v) => {
|
||||
|
|
|
@ -84,21 +84,21 @@ describe("normal behavior", () => {
|
|||
}, 100);
|
||||
expect(result).toBe("100123456");
|
||||
|
||||
var indexes = [];
|
||||
var indices = [];
|
||||
result = ["foo", 1, true].reduceRight((a, v, i) => {
|
||||
indexes.push(i);
|
||||
indices.push(i);
|
||||
});
|
||||
expect(result).toBeUndefined();
|
||||
expect(indexes.length).toBe(2);
|
||||
expect(indexes[0]).toBe(1);
|
||||
expect(indexes[1]).toBe(0);
|
||||
expect(indices.length).toBe(2);
|
||||
expect(indices[0]).toBe(1);
|
||||
expect(indices[1]).toBe(0);
|
||||
|
||||
indexes = [];
|
||||
indices = [];
|
||||
result = ["foo", 1, true].reduceRight((a, v, i) => {
|
||||
indexes.push(i);
|
||||
indices.push(i);
|
||||
}, "foo");
|
||||
expect(result).toBeUndefined();
|
||||
expect(indexes).toEqual([2, 1, 0]);
|
||||
expect(indices).toEqual([2, 1, 0]);
|
||||
|
||||
var mutable = { prop: 0 };
|
||||
result = ["foo", 1, true].reduceRight((a, v) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue