How can I write a generic container class that implements a given interface in C#?

This isn’t pretty, but it seems to work: public static class GroupGenerator { public static T Create<T>(IEnumerable<T> items) where T : class { return (T)Activator.CreateInstance(Cache<T>.Type, items); } private static class Cache<T> where T : class { internal static readonly Type Type; static Cache() { if (!typeof(T).IsInterface) { throw new InvalidOperationException(typeof(T).Name + ” is not an … Read more

c++ deque vs queue vs stack

Moron/Aryabhatta is correct, but a little more detail may be helpful. Queue and stack are higher level containers than deque, vector, or list. By this, I mean that you can build a queue or stack out of the lower level containers. For example: std::stack<int, std::deque<int> > s; std::queue<double, std::list<double> > q; Will build a stack … Read more

How to SSH into Docker?

Firstly you need to install a SSH server in the images you wish to ssh-into. You can use a base image for all your container with the ssh server installed. Then you only have to run each container mapping the ssh port (default 22) to one to the host’s ports (Remote Server in your image), … Read more

Install Oracle Instant client into Docker container for Python cx_Oracle

After many hours trying it, I finally solved it with this Dockerfile Note I am using python 3.7, Django 3.0, Oracle Database 12c and Pipenv for package management FROM python:3.7.5-slim-buster # Installing Oracle instant client WORKDIR /opt/oracle RUN apt-get update && apt-get install -y libaio1 wget unzip \ && wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip \ && unzip instantclient-basiclite-linuxx64.zip … Read more

Is there a sorted collection type in .NET?

You might want to take a look at the Wintellect Power Collections. It is available on CodePlex and contains quite a few collections that are very helpful. The OrderedBag collection in the project is exactly what you are looking for. It essentially uses a red-black tree to provide a pretty efficient sort.

General use cases for C++ containers

A picture is worth a thousand words. It’s available from nolyc, the informative bot of ##C++ on Freenode, using the command “container choice” or “containerchoice”. The link to this picture you receive in response is hosted at adrinael.net, which suggests we should thank Adrinael, member of Freenode’s ##C++ community.