Skip to main content

Questions tagged [array]

An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one (single dimensional array, or vector) or multiple indexes.

0 votes
0 answers
18 views

Identifies connected elements and faces in FE mesh

So I'm conscious that this is a weak appeal for best practices. I'm building a converter that moves generic FE meshes to an inhouse edge format in Fortran and at some point I made a truly diabolical ...
Subject303's user avatar
6 votes
7 answers
1k views

Filter non-even elements from an array

I have a method that returns an int[]. The array is made by filtering out only the even values of the array passed into the method. It works, but it's really ugly ...
Otaku's user avatar
  • 161
2 votes
1 answer
33 views

Zig: Basic map and movement logic

I'm interested about choice of types for storing coordinates; since the type for indexing an array is usize, that is what I chose. I feel something might be wrong ...
Zak's user avatar
  • 241
3 votes
1 answer
97 views

Swift Arrays: Write a rotate-right function

Task: Write a function which rotates all elements of a given array to the right. Example: [1, 2, 3] => [3, 1, 2] My solution: ...
michael.zech's user avatar
  • 4,814
1 vote
2 answers
387 views

Median of two sorted arrays in Python

Problem Statement (Source: Leetcode Problem 4: Median of Two Sorted Arrays [Hard])(Topics: [Array] [Binary Search] [Divide and Conquer]) Given two sorted arrays ...
CrSb0001's user avatar
  • 499
3 votes
1 answer
91 views

Merge discrete integer intervals

What it does The code starts with a set of integer intervals, and can add new intervals (possibly by updating existing intervals). Essentially, it is a bit array whose index starts at ...
FromTheStackAndBack's user avatar
6 votes
3 answers
333 views

Implementation of arrays that store their size

In this code I implemented arrays that store their own size before the first element. To access it you need to go back exactly sizeof(size_t) bytes back. To free it,...
yurich's user avatar
  • 165
7 votes
3 answers
990 views

Dynamic Arrays with Count / Capacity in C

I write in C for several projects (e.g. learning / teaching, coding competitions, data processing) and frequently need arrays (e.g. strings) with fast appending / concatenation / reversing. I've ...
Justin Chang's user avatar
  • 2,437
3 votes
2 answers
86 views

Optimize Working Live Search & Highlight Function

I've written a custom Live Search & Highlight function in vanilla JS. It is working and does what I expect it to. The issue is that the more items I add to the page content to search, the slower ...
codejp3's user avatar
  • 31
3 votes
2 answers
145 views

Todo List app using C

I just learned to deal with pointers and memory allocation stuff. Using that, I built a todo list app, and it works as far as I tested it. I didn't account for many user errors, so any suggestion to ...
Sarthak Hingankar's user avatar
3 votes
0 answers
98 views

Comparing two Tree sort algorithm variations implemented in Java

I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
coderodde's user avatar
  • 30.2k
0 votes
0 answers
33 views

Removing "all" entries of Type from an array (Godot Editor)

I realized I wanted a way to safeguard for null entries, not only in the inspector but via code as well. After looking through the docs and not really understanding how to make use of .any(), .all(), ....
Mike Millar's user avatar
2 votes
2 answers
135 views

Generic Dynamic Array Implementation

I wrote a dynamic array implementation in ISO C11 using void pointers. Everything I've implemented works--at least in all my tests--on a 64-bit machine. It has some vague type-checking and resizes ...
Zenais's user avatar
  • 75
1 vote
0 answers
67 views

Presence of UB and memory usage of a std::array initialization: version with temporary array on heap

I proposed several techniques to answer to https://stackoverflow.com/q/78672409/21691539. A classical way to answer would be to use std::index_sequence-based ...
Oersted's user avatar
  • 347
5 votes
2 answers
977 views

Optimized data structure mapping finite set of integers to values in C++

I'm looking for a mapping data structure, but knowing that the possible values of my keys are small numbers, I would like to trade memory for better performances (for both random access and value ...
Delgan's user avatar
  • 621

15 30 50 per page
1
2 3 4 5
142