PageRenderTime 894ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llcommon/llcommonutils.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 56 lines | 21 code | 7 blank | 28 comment | 0 complexity | 7cc12e7667acf38fb2eb4127679e6e33 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcommonutils.h
  3. * @brief Commin utils
  4. *
  5. * $LicenseInfo:firstyear=2010&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "llcommonutils.h"
  28. void LLCommonUtils::computeDifference(
  29. const uuid_vec_t& vnew,
  30. const uuid_vec_t& vcur,
  31. uuid_vec_t& vadded,
  32. uuid_vec_t& vremoved)
  33. {
  34. uuid_vec_t vnew_copy(vnew);
  35. uuid_vec_t vcur_copy(vcur);
  36. std::sort(vnew_copy.begin(), vnew_copy.end());
  37. std::sort(vcur_copy.begin(), vcur_copy.end());
  38. size_t maxsize = llmax(vnew_copy.size(), vcur_copy.size());
  39. vadded.resize(maxsize);
  40. vremoved.resize(maxsize);
  41. uuid_vec_t::iterator it;
  42. // what was removed
  43. it = set_difference(vcur_copy.begin(), vcur_copy.end(), vnew_copy.begin(), vnew_copy.end(), vremoved.begin());
  44. vremoved.erase(it, vremoved.end());
  45. // what was added
  46. it = set_difference(vnew_copy.begin(), vnew_copy.end(), vcur_copy.begin(), vcur_copy.end(), vadded.begin());
  47. vadded.erase(it, vadded.end());
  48. }
  49. // EOF