/* The following code example is taken from the book * “The C++ Standard Library – A Tutorial and Reference” * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided “as is” without express or implied * warranty, and with no claim as to its suitability for any purpose. */ #include <bitset> #include <iostream> using namespace std; int main() { /* enumeration type for the bits * – each bit represents a color */ enum Color { red, yellow, green, blue, white, black, //…, numColors }; // create bitset for all bits/colors bitset<numColors> usedColors; // set bits for two colors usedColors.set(red); usedColors.set(blue); // print some bitset data cout << “bitfield of used colors: ” << usedColors << endl; cout << “number of used colors: ” << usedColors.count() << endl; cout << “bitfield of unused colors: ” << ~usedColors << endl; // if any color is used if (usedColors.any()) { // loop over all colors for (int c = 0; c < numColors; ++c) { // if the actual color is used if (usedColors[(Color)c]) { //… } } } } /* bitfield of used colors: 001001 number of used colors: 2 bitfield of unused colors: 110110 */
Category: Root
Jul 27
Transform binary representation into integral number using bitset
/* The following code example is taken from the book * “The C++ Standard Library – A Tutorial and Reference” * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and distribute this software * is granted provided this copyright notice appears in all copies. * This software is provided “as is” without express or implied * warranty, and with no claim as to its suitability for any purpose. */ #include <bitset> #include <iostream> #include <string> #include <limits> using namespace std; int main() { /* print some numbers in binary representation */ cout << “267 as binary short: ” << bitset<numeric_limits<unsigned short>::digits>(267) << endl; cout << “267 as binary long: ” << bitset<numeric_limits<unsigned long>::digits>(267) << endl; cout << “10,000,000 with 24 bits: ” << bitset<24>(1e7) << endl; /* transform binary representation into integral number */ cout << “\”1000101011\” as number: ” << bitset<100>(string(“1000101011″)).to_ulong() << endl; } /* 267 as binary short: 0000000100001011 267 as binary long: 00000000000000000000000100001011 10,000,000 with 24 bits: 100110001001011010000000 1000101011” as number: 555 */ // create a bitset that is 8 bits long bitset<8> bs; // display that bitset for( …
Jul 26
Kentico Hosted Trial Kentico Administrator Backend Overview
Kentico Hosted Trial Kentico Administrator Backend Overview
Jul 26
নোড . জে এস । Node.js – ইভেন্ট ইমিটার (Event Emitter)
নড জেএসঃ ইভেন্ট ইমিটার রিদওয়ান বিন শামীম নড ইমিট ইভেন্টের অনেক অবজেক্ট যেমন net.Server এর সাথে কোনও সদৃশ পিয়ার যুক্ত হলে কোনও ইভেন্টকে ইমিট করে। fs.readStream কোনও ইভেন্টকে ইমিট করে যখন এর ফাইল খোলা থাকে। events.EventEmitter সব ইভেন্ট ইমিট হওয়ার উদাহরণ। ইভেন্ট ইমিটারের শ্রেণীঃ ইভেন্ট ইমিটারের শ্রেণী events module তে ব্যপিত থাকে। নিচে উদাহরণ দেয়া …
Jul 26
বাংলাদেশ কারিগরি শিক্ষা বোর্ডের অধিনে HSC BM এবং HSC VOC প্রোগ্রামে ভর্তির অনলাইন আবেদন
বাংলাদেশ কারিগরি শিক্ষা বোর্ডের অধিনে পরিচালিত HSC BM এবং HSC VOC প্রোগ্রামে (২০০৬-২০১৫ সালে SSC/সমতুল্য পাশ) ভর্তির আবেদন অনলাইনে ৩০ জুলাই ২০১৫ পর্যন্ত গ্রহণ করা হবে। ভর্তির ফলাফল ২রা আগস্ট ২০১৫ প্রকাশিত হবে। for Only HSC BM and HSC VOC Under BTEB Help Line (9:00 AM to 8:00 PM): 01732487334 01731582032
Jul 25
ইউজার ডায়াগ্রাম প্রটোকল
রিদওয়ান বিন শামীম টিসিপি/আইপি প্রটোকল স্যুইটের সরলতম ট্রান্সপোর্ট লেয়ার কমিউনিকেশন প্রটোকল হল ইউজার ডায়াগ্রাম প্রটোকল । এটিতে কম সংখ্যক যোগাযোগ কৌশল প্রয়োগ করা হয়। ইউজার ডায়াগ্রাম প্রটোকলকে অনির্ভরযোগ্য যোগাযোগ প্রটোকল বলা হলেও এটি আইপি সার্ভিস ব্যবহার করে যেটিতে সেরা সরবরাহ কৌশল ব্যবহৃত হয়। ইউজার ডায়াগ্রাম প্রটোকলে ডাটা প্যাকেট গ্রহণকারী কোনোরূপ প্রাপ্তি সংবাদ পাঠায় না …
Jul 25
ইউনিক্স বেসিক ইউটিলিটিঃ প্রিন্টিং, ইমেইল
রিদওয়ান বিন শামীম ইউনিক্স অপারেটিং সিস্টেম ও এর বেসিক কম্যান্ড সম্পর্কে আপনাদের নিশ্চয়ই কিছু ধারণা হয়েছে, এই টিউটোরিয়ালে এর এমন কিছু বেসিক ইউটিলিটি নিয়ে কাজ করা হবে যা আমাদের দৈনন্দিন জীবনে অনেক কাজে লাগে। ফাইল প্রিন্ট করা ইউনিক্স সিস্টেমে ফাইল প্রিন্ট করার আগে আমরা মার্জিন, কোনও লাইন হাইলাইট করার থাকলে তা করা ইত্যাদি সমন্বয় …
Jul 25
নোড.জেএস । Node.js – ইভেন্ট লুপ (Node.js – Event Loop)
রিদওয়ান বিন শামীম নড জেএস একক থ্রেড এপ্লিকেশন কিন্তু এটি ইভেন্ট ও কলব্যাকের সমন্বয়ের ধারনায় সমর্থন করে। যেহেতু নড জেএসের প্রতিটি এপিআই অসমন্বিত ও একক থ্রেডের, তাই এরা ফাংশন কল ব্যবহার করে সমন্বয় সাধনের জন্য। নড অবজারভার প্যাটার্ন ব্যবহার করে। নড থ্রেড ইভেন্ট লুপ রাখে, যখন কোনও টাস্ক সম্পন্ন হয় এটি সংশ্লিষ্ট ইভেন্টকে বাতিল …
