IndexBlock.cpp

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Copyright (C) 2012 Sergey Lisitsyn
00008  */
00009 
00010 #include <shogun/lib/IndexBlock.h>
00011 
00012 using namespace shogun;
00013 
00014 CIndexBlock::CIndexBlock() : CSGObject(),
00015     m_block_name("block"),
00016     m_min_index(0), m_max_index(0),
00017     m_weight(1.0), m_sub_blocks(NULL)
00018 {
00019     m_sub_blocks = new CList(true);
00020     SG_REF(m_sub_blocks);
00021 }
00022 
00023 CIndexBlock::CIndexBlock(index_t min_index, index_t max_index, 
00024              float64_t weight, const char* name) :
00025     CSGObject(), m_block_name(name),
00026     m_min_index(min_index), m_max_index(max_index),
00027     m_weight(weight), m_sub_blocks(NULL)
00028 {
00029     m_sub_blocks = new CList(true);
00030     SG_REF(m_sub_blocks);
00031 }
00032 
00033 CIndexBlock::~CIndexBlock()
00034 {
00035     SG_UNREF(m_sub_blocks);
00036 }
00037 
00038 void CIndexBlock::add_sub_block(CIndexBlock* sub_block)
00039 {
00040     ASSERT(sub_block->get_min_index()>=m_min_index);
00041     ASSERT(sub_block->get_max_index()<=m_max_index);
00042     m_sub_blocks->append_element(sub_block);
00043 }
00044 
00045 CList* CIndexBlock::get_sub_blocks()
00046 {
00047     SG_REF(m_sub_blocks);
00048     return m_sub_blocks;
00049 }
00050 
00051 int32_t CIndexBlock::get_num_sub_blocks()
00052 {
00053     return m_sub_blocks->get_num_elements();
00054 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation