Questions tagged [heterogeneous]

This tag is ambiguous. Please use other, more specific tags to narrow down the scope of your question.

This tag is ambiguous. Please use other, more specific tags to narrow down the scope of your question.

116 questions
36
votes
5 answers

Ad hoc polymorphism and heterogeneous containers with value semantics

I have a number of unrelated types that all support the same operations through overloaded free functions (ad hoc polymorphism): struct A {}; void use(int x) { std::cout << "int = " << x << std::endl; } void use(const std::string& x) { std::cout <<…
syam
  • 14,701
  • 3
  • 41
  • 65
27
votes
8 answers

Heterogeneous containers in C++

I saw this nice graphic which classifies which STL container would suit based on different requirements of data such as: -- Fixed Size Vs Variable size -- Data of same tyme Vs different type -- Sorted Vs unsorted data -- Sequential Vs random…
goldenmean
  • 18,376
  • 54
  • 154
  • 211
15
votes
2 answers

List of items of types restricted by typeclass

I'm trying to encode a list of items which have types restricted to be instances of some type class: {-# LANGUAGE RankNTypes, TypeSynonymInstances, LiberalTypeSynonyms #-} module Test where class Someable a where some :: a -> String data Some =…
andreypopp
  • 6,887
  • 5
  • 26
  • 26
12
votes
4 answers

How to use STL-compliant allocators for heterogeneous memory allocations

I'm trying to implement a class that's followed in memory by an array of some arbitrary type: template class Buf { size_t n; int refs; explicit Buf(size_t n) : n(n) { } // other declarations are here as appropriate //…
user541686
  • 205,094
  • 128
  • 528
  • 886
11
votes
1 answer

Simple usage samples for haskell Data.HList

Where can I find simple examples of usage for Data.HList? From what I read in the wiki, this tool is a "better" solution for heterogeneous lists than existential types, and I don't understand why.
tohava
  • 5,344
  • 1
  • 25
  • 47
10
votes
3 answers

Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics

I have checked over the whole web and couldn't find a solution that seems to work for me.. I have recreated my stored procedure, making sure to have these lines as first lines: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_WARNINGS…
Maude
  • 512
  • 3
  • 8
  • 23
9
votes
2 answers

How to compare two arrays of protocols for equality in Swift?

I've run into a situation that I'm sure is not that uncommon. I have two arrays of objects that conform to a protocol and I want to check if they are the equal. What I'd really like to do is this: protocol Pattern: Equatable { func…
Daniel Wood
  • 4,487
  • 3
  • 38
  • 36
8
votes
2 answers

SVN:ignore how-to and on what?

It seems to me that adding the property svn:ignore on files like .classpath would be a good idea. I use both Windows (work, ugh) and Linux development environments and every time I sync with the repository it overwrites my .classpath from whichever…
Bill Mote
  • 12,644
  • 7
  • 58
  • 82
8
votes
3 answers

Why are aggregate and fold two different APIs in Spark?

When using the Scala standard lib, I can do somthing like this: scala> val scalaList = List(1,2,3) scalaList: List[Int] = List(1, 2, 3) scala> scalaList.foldLeft(0)((acc,n)=>acc+n) res0: Int = 6 Making one Int out of many Ints. And I can do…
8
votes
1 answer

Filter usage in shapeless, Scala

It is easy to filter HList in shapeless by type: val hlist = 1 :: 2 :: "3" :: true :: false :: HNil hlist.filter[Int] But how can I make my custom type filter? I want smth like that: for example I got list of some functions: def function1(s:…
DaunnC
  • 1,301
  • 15
  • 30
7
votes
2 answers

Kubernetes cpu requests/limits in heterogeneous cluster

Kubernetes allows to specify the cpu limit and/or request for a POD. Limits and requests for CPU resources are measured in cpu units. One cpu, in Kubernetes, is equivalent to: 1 AWS vCPU 1 GCP Core 1 Azure vCore 1 IBM vCPU 1 Hyperthread on a…
7
votes
4 answers

What would be the safest way to store objects of classes derived from a common interface in a common container?

I'd like to manage a bunch of objects of classes derived from a shared interface class in a common container. To illustrate the problem, let's say I'm building a game which will contain different actors. Let's call the interface IActor and derive…
svenstaro
  • 1,783
  • 2
  • 21
  • 31
7
votes
1 answer

Heterogeneous arguments in a Scala function

How can I pass some HList as an argument? So I can make in a such way: def HFunc[F, S, T](hlist: F :: S :: T :: HNil) { // here is some code } HFunc(HList(1, true, "String")) // it works perfect But if I have a long list, and I dunno nothing…
DaunnC
  • 1,301
  • 15
  • 30
6
votes
1 answer

Creating heterogeneous arrays in Fortran

I am trying to create heterogeneous arrays that contain variables of different types, for example, [ 1.0, 7, "hi" ]. I tried to include class(*) or type(*) in the array constructor (please see the end of the following code), but gfortran5.2 simply…
roygvib
  • 7,218
  • 2
  • 19
  • 36
6
votes
4 answers

C++ How to create a heterogeneous container

I need to store a series of data-points in the form of (name, value), where the value could take different types. I am trying to use a class template for each data-point. Then for each data-point I see, I want to create a new object and push it…
Abhi
  • 1,167
  • 2
  • 14
  • 21
1
2 3 4 5 6 7 8