c ++ – Stack Interview Code methods from class nodes and smart pointers

I'm mainly looking for feedback on my use of smart pointers to implement a standard stack. For the interviewee production code, I also added a namespace and asserts to test my class. Let me know if this is suitable for an interview. I'd like to get feedback on pointer management to avoid memory leaks, such as the ability to use the classic SomeObjectNameHere * Pointer for data exchange in my change Function or the unique_ptr Swap method.

Otherwise, I have taken the feedback of all my previous posts correctly. Let me know what you think

#include 
#include 
#include 
#include 
#include 

Namespace sonsprl
{
class stack
{
Private:
class node
{   Private:
int m_data;
std :: unique_ptr m_previous;
Public:
Nodes (int data, std :: unique_ptr& Previous) {
m_data = data;
m_previous = std :: move (previous);
}
~ Node () {m_previous.reset (); }
const int data () {return m_data; }
std :: unique_ptr& previous () {return m_previous; }
};
int m_size {0};
std :: unique_ptr m_top;
Public:
~ Stack () {m_top.reset (); }
void push_back (int data) {
m_top = std :: unique_ptr(new node (data, m_top));
++ m_size;
}
void pop_back () {
if (! m_top) {
throw std :: out_of_range ("ERROR: Pop not possible, stack empty.");
}
miscellaneous
m_top = std :: move (m_top-> previous ());
--m_size;
}
}
int top () {
return m_top.get () -> data ();
}
int size () {
return m_size;
}
bool empty () {
return (m_size == 0)? true wrong;
}
void swap (stack & other_stack) {
m_top.swap (other_stack.m_top);
// Node * other_top = other_stack.m_top.release ();
// other_stack.m_top = std :: move (m_top);
// m_top = std :: unique_ptr(New node (other_top-> data (), other_top-> previous ()));
}
friend std :: ostream & operator <<(std::ostream& os, Stack& stack) {
                std::string stack_string = "";
                Node* current = stack.m_top.get();
                for(; current; current = current->previous (). get ()) {
stack_string = stack_string + & # 39; & # 39; + std :: to_string (current -> data ()) + & # 39; & # 39; + & # 39;  n & # 39 ;;
}
os << stack_string;
os << "---  n";
Return os;
}
};
}

int main ()
{
sonsprl :: Stack stack;
To attempt {
stack.pop_back ();
} catch (const std :: out_of_range & e) {
std :: cout << e.what () << & # 39 ;;
}
assert (stack.empty ());

stack.push_back (1);
stack.push_back (2);
stack.push_back (3);
assert (stack.size () == 3);
assert (stack.top () == 3);

stack.pop_back ();
stack.pop_back ();
assert (stack.size () == 1);

std :: cout << stack << & # 39;  & # 39 ;;

stack.push_back (4);
stack.push_back (4);

assert (stack.empty () == false);

sonsprl :: Stack swap_stack;
swap_stack.push_back (5);
swap_stack.push_back (6);
swap_stack.push_back (7);
swap_stack.push_back (8);
assert (swap_stack.top () == 8);

std :: cout << "pre swap  n";
std :: cout << stack << & # 39;  & # 39 ;;
std :: cout << swap_stack << & # 39 ;;
swap_stack.swap (stack);
std :: cout << "post swap  n";
std :: cout << stack << & # 39;  & # 39 ;;
std :: cout << swap_stack << & # 39 ;;

assert (stack.top () == 8);
assert (swap_stack.top () == 4);

std :: cout << "passed all stacking tests :)  n";

Return 0;
}

[WTS] Bulk IP Server ⚡ 256 IPv4 addresses meter Unmetered 1 Gbps ⚡ Quick Configuration

This is a discussion about Bulk IP Server ⚡ 256 IPv4 addresses meter Unmetered 1 Gbps ⚡ Quick Configuration within the Webmaster Marketplace Forums, part of the business category; VEEBLE – www.veeble.com

Veeble provides web hosting services such as virtual private servers, dedicated servers, remote desktop solutions, web hosting, cloud …

,

Open Source – Which methods (library or function) do cameras use to draw the histogram after computation?

What methods (library or function) do cameras use to draw a histogram after computing the required data?

I've been thinking about using gnuplot or koolplot, but these methods seem a bit slow because I need to draw a histogram in real time for videos.

What other problems can I encounter with these tools?

I do not ask for algorithms or codes. I just want to know with which tool cameras the histogram is drawn so fast.

Are there any tools like these that allow good speed and good representation of the histogram?
What do cameras really use? Please enter a source or a link. I've been stuck for a while now.

Open source camera methods (library or function) to draw the histogram after the calculation?

Which methods (library or function) do cameras use to draw the histogram after computing the required data?
I've been thinking about using gnuplot or koolplot, but these methods seem to be slow because I need to draw the histogram for video in real time. (What other problems might occur with these tools?)

I'm not asking for algorithms or code. I just want to know with which tool cameras the histogram is drawn so fast.

Are there any tools like these that allow good speed and good representation of the histogram?
which cameras really use? Please give me a source or a link that is really stuck for a while now.

why please vote, please explain to me: am I not clear with my request?
: Is there a lack of information or another problem?

Design – How do I write a class that uses other classes, but requires the same functionality if I wrap only the methods?

I want to create a class ProcessHandler for Windows that uses the WINAPI.

The ProcessHandler class should be able to use MemoryScan, KeyBoard, and Mouse emulator, DLLInjector, Hooking, ProcessInformation because I want to use some design principles. I thought I should divide each part into its own classes (eg the class MemoryScanner) and then let ProcessHandler only use the class.

Enter the image description here

Do I have to redefine the ArrayOfByte method of ProcessHandler this way?

ArrayOfByteScan () {
return memoryscanner.arrayofbyteScan ()
}

Is that a valid approach? And considered as good design?

I also do not like every class (if I do it that way) having its own HANDLE data type. For example, the class MemoryScanner and DLLInjector will need it. Is there another way to do that?

I've never used design patterns / principles and my approach would just write any method in ProcessHandler.

[WTS] Libertyvps.net NL Virtual Linux Servers | 99.9% network availability + 30% DISCOUNT!

LibertyVPS.net
Fast offshore hosting

LibertyVPS is committed to protecting your privacy, privacy and providing you with high quality hosting. We offer KVM VPS that can run Linux and Windows. We only use high quality hardware and high speed Gigabit connections. All our VPS are equipped with secure memory, high bandwidth and dedicated RAM. We accept Bitcoin as one of our many payment methods for our bitcoin vps. Bitcoin is the best and easiest way to pay online and is anonymous to protect your privacy. All Bitcoin payments are processed automatically via BitPay and credited after payment has been made.

LibertyVPS Offshore VPS is great for running websites, game servers, Bitcoin wallets, email servers, file servers, and more. All of our Linux servers have a variety of operating system templates that you can choose to install, and all resources are dedicated. The best choice for beginners or professionals is LibertyVPS Offshore VPS. Our offshore VPS are located in our NL data center. Our data center is secure and located in the offshore area for the best in privacy and security. You can use your server to host websites, download files and much more! We use the Ecatel Datacenter in Amsterdam. Ecatel uses the best network equipment, hardware and transit providers. The entire bandwidth is premium bandwidth, resulting in very low ping and very high speeds.

****************************************
SPECIAL OFFER: 30% discount in the first month
Coupon Code: I4JS661YNK
****************************************

Take a look at OUR OFFSHORE Hosting packages for Linux VPS:

Bronze VPS plan
CPU cores – 1 core
Dedicated RAM – 1 GB
Hard disk space – 25 GB
Monthly Bandwidth – 2TB
Virtualization – Linux KVM
ORDER NOW$ 19.99 / month

Silver VPS plan
CPU cores – 2 cores
Dedicated RAM – 2 GB
Hard disk space – 50 GB
Monthly bandwidth – 4 TB
Virtualization – Linux KVM
ORDER NOW$ 39.99 / month

Gold VPS plan
CPU cores – 4 cores
Dedicated RAM – 3 GB
Hard disk space – 75 GB
Monthly Bandwidth – 8TB
Virtualization – Linux KVM
ORDER NOW$ 59.99 / month

Platinum VPS plan
CPU cores – 8 cores
Dedicated memory – 4 GB
Hard disk space – 100 GB
Monthly Bandwidth – 10TB
Virtualization – Linux KVM
ORDER NOW$ 79.99 / month

Payment Methods
You can order our VPS with the following payment methods: PayPal, Bitcoin (Anonymous Shared Wallet), Perfect Money, OKPAY. If you need another payment method, we are flexible! Feel free to contact us!

Support / Contact
You can contact us via our ticket system or click here use our contact form!

Terms of Use
We do not allow: Illegal Pornography, DDoS / DoS, Malware, SPAM / Phishing, Terrorism.

,

c ++ Queue Interview Code Basic methods optimized from struct Node

With the feedback from my previous implementation, I am writing a very simple queue of struct nodes that contains only these methods get_front (), get_back (), pop_front (), push_back (), and an Ostream Friend method. I want this checked as a production code and treated as a code that could be used in an interview. I'm really curious about the approach I chose here to track the size, empty status and the back and forth hands. I fixed some of the padding issues in my data structures. I am not sure if that is superfluous or if I show my C ++ skills well.

I'd like to know if my queuing member functions have any edge cases that I do not look at and what improvements I can make overall in terms of runtime efficiency. Anyway, I can further simplify this code with C ++ 11 features, shorter variable names or smart pointers would be appreciated.

If you optionally want to free up memory / space complexity for my code, this would be a great help! I have noted some examples in the member data of my node structure.

#include 
#include 

Queue of the class
{
Private:
struct node
{
int data;
sign padding[4];
Node * previous;
Node (int data): data (data), previous (nullptr) {}
};
int _size {0};
sign padding[4];
Node * _back {nullptr};
Node * _front {nullptr};
Public:
~ Queue () {
during (_front) {
car n = _front;
_front = _front-> previous;
delete;
}
}

void pop_front () {
--_Size;
if (! _back) {
throw std :: out_of_range {"can not retrieve data from empty queue"};
}
otherwise if (_front-> previous) {
car danglingptr = _front;
_front = _front-> previous;
delete danglingptr;
}
miscellaneous
_front = _back = nullptr;
}
}
void push_back (int data) {
auto n = new node (data);
++ _ size;
if (! _back) {
_front = _back = n;
}
miscellaneous
_back-> previous = n;
_back = _back-> previous;
}
}
int get_back () {return _back? _back-> data: 0; }
int get_front () {return _front? _front-> data: 0; }
std :: size_t get_size () {return _size; }
bool is_empty () {return _size> 0; }

friend std :: ostream & operator << (std :: ostream & os, const queue & queue) {
int size = queue._size;
if (size == 0) {
os << "Queue is empty";
}
miscellaneous
for (int i = 1; i <size * 2; i ++) {os << "_"; }
os << std::endl;
                std::string queue_string = "";
                auto current = queue._front;
                for(; current; current = current->Previous) {
queue_string = std :: to_string (current-> data) + "" + queue_string;
}
os << queue_string << std :: endl;
for (int i = 1; i <size * 2; i ++) {os << "_"; }
}

Return os;
}
};

int main ()
{
queue

queue.push_back (9);
queue.push_back (8);
queue.push_back (7);
queue.push_back (6);
queue.push_back (5);

std :: cout << queue << std :: endl;
std :: cout << "back is" << std :: to_string (queue.get_back ()) << & # 39;
std :: cout << "front is" << std :: to_string (queue.get_front ()) << & # 39 ;;
std :: cout << "size is" << std :: to_string (queue.get_size ()) << " n  n";

queue.pop_front ();
queue.pop_front ();
queue.pop_front ();

std :: cout << queue << std :: endl;
std :: cout << "back is" << std :: to_string (queue.get_back ()) << & # 39;
std :: cout << "front is" << std :: to_string (queue.get_front ()) << & # 39 ;;
std :: cout << "size is" << std :: to_string (queue.get_size ()) << " n  n";

queue.pop_front ();
queue.pop_front ();

std :: cout << queue << std :: endl;
std :: cout << "back is" << std :: to_string (queue.get_back ()) << & # 39;
std :: cout << "front is" << std :: to_string (queue.get_front ()) << & # 39 ;;
std :: cout << "size is" << std :: to_string (queue.get_size ()) << " n  n";

queue.pop_front ();
}

[WTS] Bulk IP Server ⚡ 256 IPv4 addresses meter Unmetered 1 Gbps ⚡ Quick Configuration

This is a discussion about Bulk IP Server ⚡ 256 IPv4 addresses meter Unmetered 1 Gbps ⚡ Quick Configuration within the Webmaster Marketplace Forums, part of the business category; VEEBLE – www.veeble.com

Veeble provides web hosting services such as virtual private servers, dedicated servers, remote desktop solutions, web hosting, cloud …

,

numerical methods – 2D finite element code that creates a network for stress distribution [MATLAB]

I'm trying to create a finite element code that describes the voltage along a coaxial cable. I've inserted a picture of where the borders are, but I think you do not need to know much about the finite element method.

Here is the code:

Function FEM2D
%
% This function shows how the 2D Laplace equation is prescribed
% essential boundary conditions are solved by the finite element method.
%

clc, sure, close all;

% geometric parameters of a rectangular domain
% These are in cm

% *** SPLITTING REDUCED IN QUARTER SIZES # ELEMENTS ***
% *** IF LINKS ARE COMPLETELY DELETED AND INCREASED IN mm
% MESH **
Length = 12.5e-3;
Height = 10e-3;


% Element size

ElementSize = .001;

% Number of elements

NumberOfElementInX = 2 * (floor (0.5 * length / element size) +1);
NumberOfElementInY = ceil (Height / ElementSize);

Display (NumberOfElementInX);
Display (NumberOfElementInY);

ElementSizeInX = Length / NumberOfElementInX;
ElementSizeInY = Height / NumberOfElementInY;

Display (ElementSizeInX);
Display (ElementSizeInY);

% Node coordinates

NumberOfNode = (NumberOfElementInX + 1) * (NumberOfElementInY + 1);
NumberOfElement = 2 * NumberOfElementInX * NumberOfElementInY;

X = zeros (NumberOfNode, 1);
Y = zeros (NumberOfNode, 1);


for j = 1: NumberOfElementInY + 1
for i = 1: NumberOfElementInX + 1
n = (j-1) * (NumberOfElementInX + 1) + i;
X (n) = (i-1) * ElementSizeInX;
Y (n) = (j-1) * ElementSizeInY;
The End
The End



% Element node connectivity

ElementNode = zeros (NumberOfElement, 3);
for j = 1: NumberOfElementInY
for i = 1: NumberOfElementInX
n = (j-1) * NumberOfElementInX + i;
if i <= NumberOfElementInX / 2
ElementNode (2 * n-1, 1) = (j-1) * (NumberOfElementInX + 1) + i;
ElementNode (2 * n-1, 2) = j * (NumberOfElementInX + 1) + i + 1;
ElementNode (2 * n-1, 3) = j * (NumberOfElementInX + 1) + i;
ElementNode (2 * n, 1) = (j-1) * (NumberOfElementInX + 1) + i;
ElementNode (2 * n, 2) = (j-1) * (NumberOfElementInX + 1) + i + 1;
ElementNode (2 * n, 3) = j * (NumberOfElementInX + 1) + i + 1;
otherwise
ElementNode (2 * n-1, 1) = (j-1) * (NumberOfElementInX + 1) + i;
ElementNode (2 * n-1, 2) = (j-1) * (NumberOfElementInX + 1) + i + 1;
ElementNode (2 * n-1, 3) = j * (NumberOfElementInX + 1) + i;
ElementNode (2 * n, 1) = (j-1) * (NumberOfElementInX + 1) + i + 1;
ElementNode (2 * n, 2) = j * (NumberOfElementInX + 1) + i + 1;
ElementNode (2 * n, 3) = j * (NumberOfElementInX + 1) + i;
The End
The End
The End

% ElementNode = Delay (X, Y. * (1 + 0.001 * ElementSize * sin (pi * X / Length)));
%% ElementNode = delay (X, Y);

% show mesh

Trimesh (ElementNode, X, Y);
axis equal

The End

So here is the mesh I get:

Enter the image description here

The problem is that I have to find a way to create a rectangular hole in my network. This problem would apply to a normal disk when the boundaries are on the outside of my square, but with this problem the limitations are limited. How can I remove the smaller rectangle in the problem? I posted a screenshot with the dimensions of the problem I'm analyzing. Any tips would be appreciated. Enter the image description here

[WTS] Webhosting in Europe [NL]; cPanel, Softaculous, WebSiteBuilder | starting at $ 1.95 per month

VPSGet has the vision to provide quality services at affordable prices for each customer.

Our servers are located in the Tier III data center in the Netherlands.
All our shared webhosting packages are cPanel based +Softaculous + WebSiteBuilder. With Softaculous With just a few clicks, you can install a variety of scripts on your website (WordPress, Joomla, OpenCart, phpBB, Drupal, .. and many other ~ 412 scripts).

Properties:• Free Managed Service *
• SSD-based RAID 10 storage
• Xeon E5 processors
• Automatic backups on external storage included.
• Weekly malware and rootkit scan; + ClamAV
• SSH access available
• Softaculous 1Click App is being installed
• cPanel
• Website creator
• WHM reseller access [upon request]
• 99.9% uptime guarantee
• 30-day money back guarantee
• No contract
• Support around the clock (internal team)
• LiveChat during the day.
Many payment methods are accepted: Bitcoin, Paypal, Credit / Debit Cards, 2 Check Out, Payza, BankWire. Altcoins are also accepted: Litecoin, Ethereum, Zcash, Monero etc.

SH-1
$ 1.95 per month
2 GB of storage space
500 GB bandwidth
5 websites
3 databases
cPanel
Softaculous
30-day money-back guarantee
More info / Compare

SH-2
$ 3.25 per month
10 GB of storage space
1TB bandwidth
Unlimited websites
Unlimited databases
cPanel
Softaculous
SSH access available
30-day money-back guarantee
More info / Compare

SH-3
$ 5.25 per month
20 GB of hard disk space
2 TB bandwidth
Unlimited websites
Unlimited databases
cPanel
Softaculous
SSH access available
Additional IPv4 available
30-day money-back guarantee
More info / Compare

SH-4
$ 15.75 per month
60 GB hard disk space
4 TB bandwidth
Unlimited websites
Unlimited databases
cPanel
Softaculous
SSH access available
1 ipv4 included
Additional IPv4 available
30-day money-back guarantee
More info / Compare

____________________________

If you have questions for sale, please do not hesitate Contact our sales team

,