record duplication in c++ [closed]
Can anyone tell me how to delete duplicate records or avoid 开发者_运维知识库duplication in the first place?
The problem is that whenever I edit a record, a duplicate record is created.
Can anyone please send an answer??
Try to use std::map or std::set collections. They don't store duplicates. Some containers have methods like unique() or you can just use unique() or unique_if() algorithms. By the way where do you duplicate records? Is it a problem with ado(.net) usage or maybe with some specific collection you use? Where do you see duplicated records? In memory, in db or maybe in some file?
Alek
The general approach to avoiding duplicates, regardless of language, is to use a hashtable to store your records. This assumes there is a field which serves as a unique identifier. Doctor Dobb's Journal as an article on C++ and hashing.
精彩评论