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
4
votes
2answers
83 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 ...
2
votes
0answers
24 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 ...
2
votes
0answers
30 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 ...
7
votes
1answer
487 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 ...
4
votes
3answers
428 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'...
1
vote
1answer
2k 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. ...
2
votes
1answer
79 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 ...
2
votes
2answers
56 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: ...
2
votes
1answer
41 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); ...
7
votes
4answers
1k 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 ...
3
votes
0answers
837 views

c++ forward implementation

this is my implementation of std::forward ...
-1
votes
1answer
4k 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 ...
3
votes
0answers
103 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: ...
2
votes
0answers
427 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 ...
4
votes
1answer
60 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 ...
11
votes
1answer
278 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 ...
6
votes
1answer
134 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 ...
2
votes
1answer
180 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 + ...
2
votes
1answer
1k 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 ...
0
votes
0answers
441 views

Copy-on-write linked list with value semantics

I'm implementing a SinglyLinkedList struct that uses a private Node class in its implementation. (See this Gist.) ...
6
votes
3answers
308 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 ...
1
vote
1answer
294 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 ...
1
vote
2answers
377 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 ...
7
votes
2answers
4k 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. ...
10
votes
3answers
3k 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 ...
2
votes
1answer
5k 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 ...
7
votes
1answer
152 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 ...
3
votes
0answers
1k views

Universal “call” function

I need a function call(f, args...) which calls the "function" f with the arguments args.... ...
2
votes
2answers
3k 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 ...
1
vote
2answers
454 views

Deep reference and object passing

I'm curious if this is the right way of going about the issue: ...
5
votes
2answers
12k views

Passing parameters by reference [closed]

Wouldn't it be better to always pass parameters by reference to avoid creating unnecessary copies? ...
4
votes
4answers
185 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: ...
3
votes
2answers
915 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. ...