Questions tagged [reference]

A reference is a value that enables a program to indirectly access a particular datum, such as a variable or a record, in the computer's memory or in some other storage device.

Filter by
Sorted by
Tagged with
-3 votes
1 answer
55 views

Should a typecast to a unsigned long reference be used while calling a function or another unsigned long variable should be created? [closed]

I was working on a code base where I have a function definition like this: ...
Himanshuman's user avatar
1 vote
1 answer
38 views

Moveable Points - Update variable without Re-referencing variable? Event Subscriptions? (C#, Unity)

So I have this helper script that I use to move points around manually while debugging: ...
FaffyWaffles's user avatar
0 votes
2 answers
195 views

Slice function for C

I am trying to create a non-generic slice function. I want a 'view' not a copy. The scan_from arg is so that successive calls ...
A T's user avatar
  • 495
0 votes
1 answer
131 views

Referenceable<T>: A Java Generic Class Used for Creating Objects That can be Mutated

...
Captain Hatteras's user avatar
0 votes
1 answer
607 views

How to collect reference values from hashmap?

I have written a code snippet to use HashMap<String, Vec<&String>> as the main data structure, and finally, I want to return a collected ...
prehistoricpenguin's user avatar
1 vote
1 answer
50 views

Dropping a row in a dataframe

I have made a function to drop a row in a pandas.DataFrame. Since, in general, the input dataframe of a function is just a reference to the dataframe. So any change made in that function to the ...
aura's user avatar
  • 251
2 votes
1 answer
265 views

Handling Rc pointers correctly in a parent/children tree

Needs A container holds two collections: Parent instances and Child instances; their items can be searched by name; A child can ...
yolenoyer's user avatar
  • 183
4 votes
1 answer
2k views

C++ Optional Reference

Here is a good article on an optional reference type in C++. They discuss std::optional<T&>, but as that doesn't compile I have made my own. One purpose ...
Blue7's user avatar
  • 373
5 votes
0 answers
121 views

Production planner

I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to ...
MSOACC's user avatar
  • 211
2 votes
0 answers
129 views

Access a variable after several references

I have a team lead that used to write references in a single script then access it in every script. Like for accessing a variable he has to write code in this way ...
Muhammad Faizan Khan's user avatar
4 votes
2 answers
186 views

Music Theory: The Basics - a Ring

I've recently started building an API that allows a consumer to create and manipulate musical entities such as notes, intervals, scales and chords. The first step is to create a a foundation of base ...
dfhwze's user avatar
  • 13.9k
2 votes
0 answers
26 views

Modelling a program with modules, symbols, and dependencies

My scenario is the following: I'm modelling a Program which has many Modules. Each Module has Symbols, some of which pointing at dependencies, which are other Modules. So a Module can be pointed to by ...
Thibaut Schaeffer's user avatar
4 votes
1 answer
225 views

Passing file identifiers to all subroutines of fortran code

The Fortran program 'MAIN' below calls 3 subroutines. It opens a file if it is not present, (overwrites if it is already present). writes something on the file using the file identifier integer and ...
Ather Cheema's user avatar
8 votes
1 answer
520 views

Getting ready for Nullable Reference Types

Looking forward for C# Nullable Reference Types in C# 8.0. I do not like to use the preview implementation in a production code though, so just went with these simple helper classes intending them to ...
Dmitry Nogin's user avatar
  • 6,113
4 votes
3 answers
692 views

Using an offset variable to keep track of the next item in a Rust array

I am using an offset variable to track the iteration position, and modifying / returning it. Is the below considered bad practice in Rust? I ask this because I don'...
Ross MacArthur's user avatar
1 vote
1 answer
5k views

Javascript Stringify Nested Objects with Loop References

I created these functions that will take any object and stringify it, and can then de-stringify it later. ...
Markus Fjellheim's user avatar
2 votes
1 answer
301 views

Simple Python module to test dictionaries

I have some hardware for which I have a driver for which I have a library which can be used to easily configure and probe the device. Now I want to add support for this library to python because the ...
cypheratheist's user avatar
2 votes
2 answers
112 views

Variables, references and pointers - Write the function set (…) so that the following code works correctly

I have following homework exercise from lecture "Variables, references and pointers": Write the function set (...) so that the following code works correctly: ...
user avatar
2 votes
1 answer
98 views

Variables, references and pointers - Write the function zero (...) so that the following code works correctly

I have following homework exercise from lecture "Variables, references and pointers": Write the function zero (...) so that the following code works correctly: int x = 3; zero(x); ...
user avatar
8 votes
4 answers
3k views

Accept either a existing stream or a filename (to be opened) in a constructor

Context: In a larger project, I am trying to build an utility class to encapsulate the parsing of input data. And I want it to be able to process either an already existing input stream, or a file ...
Serge Ballesta's user avatar
5 votes
1 answer
2k views

c++ forward implementation

this is my implementation of std::forward ...
Fletcher Blight's user avatar
-1 votes
1 answer
6k views

Pass object by reference when containing a vector [closed]

I have a class that contains (among other things) a large vector. I need to pass an object of this class to a function. According to best practices, in C++ vectors and arrays should be passed by ...
BillyJean's user avatar
  • 161
3 votes
0 answers
238 views

Creating a TSP level with a linked list

I am trying to solve the Travelling Salesman Problem. This function creates the first level in the form of a linked list. This is what the levels look like: This is the code that creates it: ...
HelloImJon's user avatar
2 votes
0 answers
539 views

Reference wrapper for functions overloadings and universal references

I have design a little class to allow to overload a function with universal references for a known type, but I'm not sure if that class will work as expected in any contexts. The indended purpose is ...
ABu's user avatar
  • 143
5 votes
1 answer
83 views

Fetching files or directories in a given directory

This is a self-teaching implementation to get files for a given directory in order to simplify os.Walk in Go (avoid to pass a func for recursively walking across ...
Natalie Perret's user avatar
12 votes
1 answer
914 views

An optional_ref<T>

I omitted all free operators but the equality comparisons ones because of verbosity. I am glad about any comments and improvements. Motivation I know that optional references are equivalent to ...
Maikel's user avatar
  • 740
6 votes
1 answer
253 views

Using get-setf-expansion

In a previous post at Simplifying complex setf expressions, @sds suggested using the get-setf-expansion macro for implementing place modification, as discussed in ...
davypough's user avatar
  • 415
2 votes
1 answer
337 views

Templated double ended queue (deque) move semantics edge cases C++

My original deque implementation and efficiency question lacked move semantics. After ratchet freak provided an example of how to define them I decided to try adding them to my deque. The unit test + ...
TOM__'s user avatar
  • 105
2 votes
1 answer
2k views

Ensure that ICommand implementation properly uses weak references

I am building an implementation of System.Windows.Input.ICommand that is like the commonly used RelayCommand, but doesn't keep a ...
AlexKven's user avatar
6 votes
3 answers
1k views

View programming pattern in C++ without raw pointers

I'm trying to achieve, for lack of a better term, a "view" pattern in C++. It's probably most comparable to "views" in the Database world, where one can make a query, and then perhaps aggregate the ...
matt_fabina's user avatar
1 vote
1 answer
360 views

Binary Search Tree insert while keeping track of parent for node to be added - iteration 2

Follow up question to Binary Search Tree insert while keeping track of parent for node to be added I am implementing a red black tree for fun and am wondering how I should modify my basic BST ...
httpNick's user avatar
  • 125
1 vote
2 answers
579 views

Binary Search Tree insert while keeping track of parent for node to be added

This question has a follow up question: Binary Search Tree insert while keeping track of parent for node to be added - iteration 2 I am implementing a red black tree for fun and am wondering how I ...
httpNick's user avatar
  • 125
7 votes
2 answers
6k views

Calculating the price of movie tickets based on multiple inputs

I have modularized my code and currently my "main" function is movieSalesReport(). I am coming from Python where you can have the functions return multiple values. ...
Clever Programmer's user avatar
10 votes
3 answers
4k views

"Suspicious comparison of integer references" while checking for a monotonically increasing sequence

I have the following code which iterates on an Integer[] and makes sure that the the values in the array are in ascending order and that there are no neighbouring ...
Rich's user avatar
  • 237
2 votes
1 answer
7k views

StringRef - read only std::string like class similar to boost::string_ref

Idea behind the class is same as boost::string_ref or llvm::SrtingRef. StringRef is immutable and not-owning. I did not ...
Nick's user avatar
  • 1,490
7 votes
1 answer
157 views

Displaying a video player to eligible users

I posted this on Stack Overflow, but it was suggested that I move it over to Code Review. I would like some feedback on the way I decided to clean up code from the in a .NET project that had ...
tophstar's user avatar
3 votes
0 answers
1k views

Universal "call" function

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
leemes's user avatar
  • 495
2 votes
2 answers
4k views

Writing a class for common block of code used in many other classes

In this I have written the setAnalyticsInfo() method. The code inside this is common to almost all other (30) classes, so I have created ...
Programmer's user avatar
1 vote
2 answers
464 views

Deep reference and object passing

I'm curious if this is the right way of going about the issue: ...
Gregorio Di Stefano's user avatar
6 votes
2 answers
13k views

Passing parameters by reference [closed]

Wouldn't it be better to always pass parameters by reference to avoid creating unnecessary copies? ...
user9029342's user avatar
4 votes
4 answers
197 views

Reference type and constructors [closed]

Code in Java but should be readable also for c#... Let's assume I have a class with some reference types. Example: ...
radekEm's user avatar
  • 934
3 votes
2 answers
1k views

Am I using C++ pointers and references correctly?

I am a newbie to C++ programming and am currently reading this book called Jumping to C++ by Alex Allain. I have finished the pointers chapter and I am doing the exercises at the end of the chapter. ...
Rojee's user avatar
  • 33