|
Hi, thank you for replying. Your solution will work great as it allows two or more holidays to have the same ranking value.
I can use guard clauses to prevent duplicate ranking values if there is a need for them to be unique.
modified 22-Nov-16 17:22pm.
|
|
|
|
|
Another easy way to do this is using Dictionary<int, string> [^] type. This type will hold the weight assigned to vacation, as well as the name of it in string. Then you can easily sort them using their key.
You need to store both of values (name + weight given) to the dictionary, no additional type generation is required as the dictionary object is a generic type.
This[^] link has a wonderful example of what you are trying to achieve.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
IIRC, a dictionary can't have duplicate keys. This would mean that two holidays cannot be ranked "equal".
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Oh.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Hi, thank you all for replying. I think using a dictionary is good solution if I want keys to be unique.
modified 22-Nov-16 11:33am.
|
|
|
|
|
Quote: if I do not want the duplicate keys. Of course that will be suitable in this case.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
List<Tuple<int, string>> holidays = new List<Tuple<int, string>>();
holidays.Add( new Tuple<int, string>( 5, "Veteran's Day" ) );
holidays.Add( new Tuple<int, string>( 3, "July Fourth" ) );
holidays.Add( new Tuple<int, string>( 1, "Christmas" ) );
holidays.Add( new Tuple<int, string>( 2, "New Year" ) );
holidays.Add( new Tuple<int, string>( 6, "Valentine's Day" ) );
holidays.Add( new Tuple<int, string>( 4, "Thanksgiving" ) );
holidays
.OrderBy( h => h.Item1 )
.ToList()
.ForEach( h => Console.WriteLine( "Holiday: {0}", h.Item2 ) );
|
|
|
|
|
This algorithms are text based.Do not tell me convert image to base64 because suppose that an image 10 mb convert base64 than output is 15 mb so image represent 15 mb ,algortihms compress then compresed file is 12 mb this is reverse compression.I want better compressionCould you help me ?
|
|
|
|
|
Basically? Don't.
Huffman and RLE are text based - they only work at all well with data in which there there are "commonly used" characters and "uncommonly used" characters, or "runs" of identical data - binary data such as an image does not generally exhibit this, except in unusual circumstances.
When you add in that PNG and CR2 files are already compressed using a lossless method, and you will find that basic (or even advanced) compression techniques do not work well in gaining further size reduction anyway.
Bitmaps compress well using normal compression for binary data such as ZIP, but PNG and CR2 don't.
None of them will give significant results with Huffman or RLE compression.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
So Any images can not comrpess wiht huffman or rle ?
|
|
|
|
|
You have to cherry pick the image. Most image formats are already compressed and will not compress further with huffman and/or RLE.
Stop looking at the image itself and start looking at the data in the file if you want to look at how you're going to compress what has already been compressed.
In a compressed image, there are no "run lengths". They've already been compressed, so RLE isn't going to do anything at all. Also, Huffman, or some derivative of it, has probably already been used on the image so that's not going to get you anywhere either.
The algorithms you've chosen will only work on uncompressed formats, like .BMP.
|
|
|
|
|
How to compress :BMP extension picture wiht huffman.What do ı need do ?
|
|
|
|
|
Instead of using characters, you convert your Huffman code to use bytes. The algorithm really doesn't change.
|
|
|
|
|
You have asked variations on this question since the end of October. Do you think the answers will change?
This space for rent
|
|
|
|
|
I want to know how to compress the image in the uncompressed form. These algorithms are text based. Base64 does not work. There must be another way. You are asking me to repeat the questions instead of helping me.
|
|
|
|
|
I'm not asking you to repeat the questions; I'm saying that the answers you get aren't going to change just because you ask them again. Apart from bitmaps and RAW files, graphics files tend to be compressed which means that you're not going to get the benefits you think you're going to get. You do understand graphic file formats don't you? If not, I suggest that you need to go and read up on them before you try anything else.
This space for rent
|
|
|
|
|
|
|
You really aren't listening to anything we tell you, are you?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Because you didnt show me how to do that.
Bitmap is not compressed.Bitmaps can be compress with huffman but how why dont u understand me ?
|
|
|
|
|
Image files are just streams of bytes, so you can compress them with any of the compression methods. The point that people are trying to make is that it is largely not worth it since so many image types are already compressed. And the rest tend not to compress well because of the structure of the data. If you really want to prove this then try it with a few files of your own and see how much you can compress them.
|
|
|
|
|
I did not know this. That's something interesting I learned today.
This space for rent
|
|
|
|
|
It makes sense when you think of the pixel density on some of the cameras now.
The uncompressed file size from this beast: Canon 120MP DSLR Shows Off its Stuff at Canon Expo[^] doesn't bear thinking about! (Nor does it's price, I suspect)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
OriginalGriff wrote: "runs" of identical data - binary data such as an image does not generally exhibit this, except in unusual circumstances. Draw a bitmap in paint, 300x300 pixels. Make all pixels black.
The problem is that someone is trying to compress data that is already compressed.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That's one of the unusual circumstances, yes!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|