uniqueness

Is it possible for compression algorithms to generate identical output for two different files?

I would like to know if compression algorithms always generate unique output for two different sets of files. Say, I have two files A and B, and say I am applying a compression algorithm (for instance like PKZIP - this could be any compression algorithm) for each of these files to get A.zip and B.zip respectively. Is it possible for A.z...

What is the most performant way to check for existence with a collection of integers?

I have a large list of integers that are sent to my webservice. Our business rules state that these values must be unique. What is the most performant way to figure out if there are any duplicates? I dont need to know the values, I only need to know if 2 of the values are equal. At first I was thinking about using a Generic List of i...

Xslt - Enforcing @attribute uniqueness.

I rarely work with xslt's so I'm not the greatest at it, but, I was wondering how to go about solving this problem: <Element> <childElement type="type1">Bob</childElement> <childElement type="type1">Smith</childElement> <childElement type="type2">Bob</childElement> </Element>" I want to enforce @type uniqueness, where I would...

Unique set of strings in C#

I have a list of strings, I need to be able to simply probe if a new string is in the table or not. When the list is large, testing a simple list directly is pretty inefficient... so typically I use a Dictionary to get constant lookup speeds, although I don't actually care about the value. This seems like a misuse of a dictionary, so I'm...

What is a good way to check if an image is unique using PHP?

What is the best way to check if an image is unique using PHP? Say I have a directory of about 30 images (about 500*500 pixels), and someone uploads another picture, what is a good way to check if the uploaded image is not yet in the directory? Is there some sort of way to create hash's of images which can be easily compared? I then cou...

Core Data uniqueness

Hi everyone, Is there any way I can validate a value updated in a Core Data entity's property against values of the property in other entities in the collection? At the moment I create an entity with some default values, add it to arrangedObjects, then get the user to modify the various property values. However, I would like to check a...

Rails Model multiple column uniqueness

I am making a Viewer model with belongs_to :users belongs_to :orders that joins the models Users and Orders with a :has_many :through => :viewers. And the Viewer model has the attributes of user_id and order_id. How would I set it up so that new viewers are only accepted if both user_id and order_id are unique in the same row? I re...

mongoid uniqueness validation many-to-many relation

I have following association class Employee include Mongoid::Document employee_id :name references_many :companies, stored_as => :array, :inverse_of => :employees end class Company include Mongoid::Document field :name references_many :employees, stored_as => :array, :inverse_of => :companies end Now How can I check the uni...