C- trying to code a 'spare array'; 'enum' fauled.


 
Thread Tools Search this Thread
Top Forums Programming C- trying to code a 'spare array'; 'enum' fauled.
# 8  
Old 09-11-2012
OK, after checking, I should admit, that I was wrong!
Corrona688, you ar ecompletely right, and I am not able to use 'enum' like 'maping' definition to indexes of info-struct array!
No way to refer a label by a string: that what was in my mind when I said that I can do it for string - integer relation.

Thus, I do not see a way to get dirrect referensing in form of associative aray without or search processing on each request, or look-up or maping array, that makes solution not sparse (and for int-int makes no sence: same type!)

Thank you for dissucing it with me and letting realize it!
# 9  
Old 09-11-2012
Quote:
Originally Posted by alex_5161
That makes solution not sparse (and for int-int makes no sence: same type!)
If you wanted a truly sparse solution I already gave you that. Even if it was done by the compiler, it'd still need to search somehow if it didn't use a big table. It's not psychic either, after all. You wanted a solution with guaranteed fixed search time, which even hash tables can't do. It has to be an array.

256 integer elements is one kilobyte of memory. That's not a lot. It can fit in a modern processor's cache many times over. And if you know you have fewer elements, you can make it smaller.

I think it makes plenty of sense to use an array. You see it happen all the time. When you build a processor using the lex and yacc tools, for instance, what does it use for state lookups? Integer arrays.

Last edited by Corona688; 09-11-2012 at 03:39 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to determine if i have spare disks in Solaris?

Hi Guys, obviously new to SOLARIS SUN SPARC 5.10 I would really appreciate if you help me see how to find free disks available in my system. Like i am a linux admin. If i want to grow a file system in linux. I would first have a look at my volume groups to see if they have free PEs if not then... (2 Replies)
Discussion started by: aiqbal
2 Replies

2. Programming

Mixed enum types - coverity defect

Hi All, I came across this error "MIXING ENUM TYPES" when I run my C program against the Coverity Tool. I've made many search relating to the error, but I didnt find the exact solution. Can anyone help me to overcome this.? Thanks in Advance.!! (3 Replies)
Discussion started by: Parameswaran
3 Replies

3. Solaris

How to get spare disks working

Dears how can i make this spare disks working online to replace a defective disks vxdisk list DEVICE TYPE DISK GROUP STATUS c0t10d0s2 sliced - - error c0t11d0s2 sliced disk08 rootdg online c1t16d0s2 sliced ... (3 Replies)
Discussion started by: thecobra151
3 Replies

4. Programming

enum and C preprocessor

Say I have a list of enumerations I wish to use to select a variable at compile-time: enum pins { PIN_A=1, PIN_B=7, PIN_C=6, } int VAR1, VAR2, VAR3, VAR4, VAR5, VAR6, VAR7; #define PIN_TO_VAR(NUM) VAR ## NUM int main(void) { PIN_TO_VAR(PIN_A)=32;... (2 Replies)
Discussion started by: Corona688
2 Replies

5. Solaris

Hot Spare replacement

Hi Guys, Can Someone pls let me know the thorough process for Hot spare replacement as current Hot spare slice has broken down . :mad: Thanks ---------- Post updated at 06:34 PM ---------- Previous update was at 05:21 PM ---------- Update : Its a solaris 10 box (1 Reply)
Discussion started by: Solarister
1 Replies

6. Solaris

Hot Spare pool

One more query in SVM :) Now with hot spare spool... I can understand adding/replacing a slice in particular hot spare pool with "-a / -r" option (or) adding a slice to all existing hot spare pool with "-all" option. Here my query is for deleting, we have only option "-d". 1) If the hot... (2 Replies)
Discussion started by: gowthamakanthan
2 Replies

7. Programming

enum in c++

#include <iostream> #include <stdio.h> using namespace std; typedef struct A { enum a{ red,blue,green}a; }obj11; obj11 obj1; int main() { //obj1.a=red; // how to set variable ? cout<<"sizeof struct is n"<<sizeof(obj1); cout<<"obj1.a is"<<obj1.a; if... (1 Reply)
Discussion started by: crackthehit007
1 Replies

8. IP Networking

DNS ENUM RR interpretation

Hi Guys, This is really really urgent. Am looking out for some quick answers. I'm developing a DNS Resolver client that interprets DNS Query repsonses & pass on the needful to DNS applications. When an ENUM query(modified to an nslookup naptr query) is issued & an NAPTR RR(Resource Record)... (1 Reply)
Discussion started by: smanu
1 Replies

9. Programming

what is the base type of enum

helo i have asked in exam what that what is the base type of enum options are given bewlo (1) long int (2) short int (3) signed int (4) unsigned int can u tell me what is the exact answer from the above option Regards, Amit (1 Reply)
Discussion started by: amitpansuria
1 Replies

10. UNIX for Dummies Questions & Answers

Vfstab on spare disk - HOW ? Mount ?

Hi, guys ! Could someone clarify one thing for me: I start machine from disk0, and want to check the /etc/vfstab on disk1. How do i do it ? Tried to write: cd / mount /dev/dsk/c0t1d0s0 /mnt But if I do cd /mnt, it is empty. I expected to see disk1 there ? Or am I wrong ? How do I... (3 Replies)
Discussion started by: DGoubine
3 Replies
Login or Register to Ask a Question